-
Notifications
You must be signed in to change notification settings - Fork 0
β‘ Bolt: Optimize Column Name Resolution from Edge Handles #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ebcfc76
4071df1
8988c15
cdd5ab4
2eb62ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import type { Node, Edge } from '@xyflow/react'; | |
| import { normalizeBusinessGroupColor } from './businessGroups'; | ||
| import type { IndexRecommendation } from './cardinality'; | ||
| import type { ForeignKeyEdgeData, TableNodeData } from './convert'; | ||
| import { sourceColumnHandleId, targetColumnHandleId } from './handleUtils'; | ||
| import { parseColumnNameFromHandle, sourceColumnHandleId, targetColumnHandleId } from './handleUtils'; | ||
|
|
||
| export * from './exportDataDictionary'; | ||
|
|
||
|
|
@@ -67,6 +67,23 @@ function fkColumnsForEdge( | |
| return { sourceColumns, targetColumns }; | ||
| } | ||
|
|
||
| const parsedSource = edge.sourceHandle ? parseColumnNameFromHandle(edge.sourceHandle) : null; | ||
| const parsedTarget = edge.targetHandle ? parseColumnNameFromHandle(edge.targetHandle) : null; | ||
|
|
||
| if (parsedSource !== null && parsedTarget !== null) { | ||
| // Validate that the parsed column actually exists in the node data | ||
| const sourceColumnsArr = sourceNode.data.columns || []; | ||
| const targetColumnsArr = targetNode.data.columns || []; | ||
|
|
||
| // Check existence using .some() | ||
| const sourceExists = sourceColumnsArr.some((c) => c && c.column_name === parsedSource); | ||
| const targetExists = targetColumnsArr.some((c) => c && c.column_name === parsedTarget); | ||
|
|
||
| if (sourceExists && targetExists) { | ||
| return { sourceColumns: [parsedSource], targetColumns: [parsedTarget] }; | ||
| } | ||
| } | ||
|
Comment on lines
+70
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Info: Fast path only accelerates, does not change results
Was this helpful? React with π or π to provide feedback. |
||
|
|
||
| const sourceHandleColumn = (sourceNode.data.columns || []) | ||
| .find((column) => sourceColumnHandleId(column.column_name) === edge.sourceHandle) | ||
| ?.column_name; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,15 @@ export function sourceColumnHandleId(columnName: string): string { | |
| export function targetColumnHandleId(columnName: string): string { | ||
| return `tgt-${sanitizeHandleId(columnName)}` | ||
| } | ||
|
|
||
| export function parseColumnNameFromHandle(handleId: string): string | null { | ||
| const prefixMatch = handleId.match(/^(?:src-|tgt-)?c-(.+)$/); | ||
| if (!prefixMatch || !prefixMatch[1]) return null; | ||
| const encoded = prefixMatch[1]; | ||
| if (encoded === 'empty') return ''; | ||
| try { | ||
| return encoded.split('-').map(code => String.fromCodePoint(parseInt(code, 16))).join(''); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π― Functional Correctness | π‘ Minor | β‘ Quick win π Supported by static analysisπ Script executed: #!/usr/bin/env bash
set -euo pipefail
node <<'NODE'
if (parseInt('61zz', 16) !== 0x61) {
throw new Error('Unexpected parseInt behavior');
}
NODE
rg -n -C 3 'parseColumnNameFromHandle|malformed|empty|fromCodePoint' \
frontend/src/erd/handleUtils.test.tsRepository: ContextualWisdomLab/pg-erd-cloud Length of output: 415 π Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- handleUtils.ts ---'
cat -n frontend/src/erd/handleUtils.ts
printf '%s\n' '--- focused tests ---'
if [ -f frontend/src/erd/handleUtils.test.ts ]; then
cat -n frontend/src/erd/handleUtils.test.ts
else
printf '%s\n' 'handleUtils.test.ts not found'
fi
printf '%s\n' '--- direct callers and related handle parsing ---'
rg -n -C 4 'parseColumnNameFromHandle|sanitizeHandleId|fromCodePoint|src-c-' frontend/src
printf '%s\n' '--- applicable repository conventions ---'
find /tmp/coderabbit-repo-knowledge/contextualwisdomlab-pg-erd-cloud-d2563f2a -path '*/\*.md' -print \
| while IFS= read -r f; do
case "$f" in
*/frontend/*|*/learnings/*) printf '%s\n' "--- $f ---"; head -120 "$f" ;;
esac
doneRepository: ContextualWisdomLab/pg-erd-cloud Length of output: 12834 π Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- export handle resolution ---'
cat -n frontend/src/erd/export.ts | sed -n '35,100p'
printf '%s\n' '--- parser test coverage and exports ---'
rg -n -C 5 'parseColumnNameFromHandle|sourceColumnHandleId|targetColumnHandleId|exportDictionary' \
frontend/src/erd --glob '*.{ts,tsx}'
printf '%s\n' '--- applicable scoped conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/contextualwisdomlab-pg-erd-cloud-d2563f2a -type f -name '*.md' -print \
| while IFS= read -r f; do
printf '%s\n' "--- $f ---"
head -120 "$f"
doneRepository: ContextualWisdomLab/pg-erd-cloud Length of output: 39652 μλͺ»λ hexadecimal ν ν°μ κ±°λΆνμΈμ.
π€ Prompt for AI AgentsSource: Coding guidelines |
||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
Comment on lines
+18
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Info: New parse function lacks a unit test
Was this helpful? React with π or π to provide feedback. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ποΈ Data Integrity & Integration | π‘ Minor | β‘ Quick win
π Supported by static analysis
π Script executed:
Repository: ContextualWisdomLab/pg-erd-cloud
Length of output: 28710
π Script executed:
Repository: ContextualWisdomLab/pg-erd-cloud
Length of output: 16497
π Script executed:
Repository: ContextualWisdomLab/pg-erd-cloud
Length of output: 4133
λ°©ν₯λ³ νΈλ€ prefixλ₯Ό κ²μ¦νμΈμ.
exportDDLμ λ°©ν₯κ³Ό 무κ΄νparseColumnNameFromHandleμ κ²°κ³Όλ₯Ό μΈλ ν€ μ»¬λΌμΌλ‘ μ¬μ©ν©λλ€. λ°λΌμsourceHandleμtgt-,targetHandleμsrc-prefixκ° μμΌλ©΄ μλͺ»λ λ§€νμ DDLλ‘ λ΄λ³΄λΌ μ μμ΅λλ€. λ°©ν₯λ³ prefixλ₯Ό κ²μ¦νκ³ , ν΄λΉ μ‘°ν©μ λνexportDDLνκ· ν μ€νΈλ₯Ό μΆκ°νμΈμ.π€ Prompt for AI Agents
Source: Coding guidelines