-
Notifications
You must be signed in to change notification settings - Fork 0
fix: DBML, Mermaid, Prisma Export Handle Parsing 오류 수정 #1064
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
29a4c1f
5c907d1
1175da7
8a68a17
ff01d9c
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import type { Node, Edge } from "@xyflow/react"; | ||
| import type { TableNodeData, ForeignKeyEdgeData } from "./convert"; | ||
| import { parseColumnNameFromHandle } from "./handleUtils"; | ||
|
|
||
| function escapeString(str: string): string { | ||
| return str.replace(/'/g, "''"); | ||
|
|
@@ -86,11 +87,24 @@ export function exportDbml( | |
| let targetCols: string[] = []; | ||
|
|
||
| if (edgeData?.sourceColumns && edgeData?.targetColumns) { | ||
| sourceCols = edgeData.sourceColumns.map(safeId); | ||
| targetCols = edgeData.targetColumns.map(safeId); | ||
| const sourceExists = edgeData.sourceColumns.every(col => (sourceNode.data.columns || []).some(c => c && c.column_name === col)); | ||
| const targetExists = edgeData.targetColumns.every(col => (targetNode.data.columns || []).some(c => c && c.column_name === col)); | ||
|
|
||
| if (sourceExists && targetExists) { | ||
| sourceCols = edgeData.sourceColumns.map(safeId); | ||
| targetCols = edgeData.targetColumns.map(safeId); | ||
| } | ||
| } else if (edge.sourceHandle && edge.targetHandle) { | ||
| sourceCols = [safeId(edge.sourceHandle.replace('src-', ''))]; | ||
| targetCols = [safeId(edge.targetHandle.replace('tgt-', ''))]; | ||
| const parsedSource = parseColumnNameFromHandle(edge.sourceHandle); | ||
| const parsedTarget = parseColumnNameFromHandle(edge.targetHandle); | ||
|
|
||
| const sourceExists = (sourceNode.data.columns || []).some(c => c && c.column_name === parsedSource); | ||
| const targetExists = (targetNode.data.columns || []).some(c => c && c.column_name === parsedTarget); | ||
|
|
||
| if (sourceExists && targetExists) { | ||
| sourceCols = [safeId(parsedSource)]; | ||
| targetCols = [safeId(parsedTarget)]; | ||
|
Comment on lines
+101
to
+106
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. 🟡 Deleted-column relations survive export After a relation column is deleted, Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| } | ||
| } | ||
|
|
||
| if (sourceCols.length > 0 && targetCols.length > 0) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import type { Node, Edge } from "@xyflow/react"; | ||
| import type { TableNodeData } from "./convert"; | ||
| import { parseColumnNameFromHandle } from "./handleUtils"; | ||
| import { sanitizeHandleId } from "./handleUtils"; | ||
|
|
||
| function sanitizeName(name: string): string { | ||
|
|
@@ -69,19 +70,31 @@ export function exportPrisma( | |
| const relName = sanitizeName(String(edge.label || `${sourceNode.data.title}_${targetNode.data.title}`)); | ||
|
|
||
| let sourceField = ""; | ||
| let sourceValid = true; | ||
| if (edge.sourceHandle?.startsWith("src-")) { | ||
| sourceField = edge.sourceHandle.slice(4); | ||
| fkNodeColumnPairs.add(`${edge.source}:${sourceField}`); | ||
| const parsedSource = parseColumnNameFromHandle(edge.sourceHandle); | ||
| sourceValid = (sourceNode.data.columns || []).some(c => c && c.column_name === parsedSource); | ||
| if (sourceValid) { | ||
| sourceField = parsedSource; | ||
| fkNodeColumnPairs.add(`${edge.source}:${sanitizeHandleId(parsedSource)}`); | ||
| } | ||
| } else if (!edge.sourceHandle) { | ||
| fkNodesWithoutHandles.add(edge.source); | ||
| } | ||
|
|
||
| let targetField = "id"; // fallback | ||
| let targetValid = true; | ||
| if (edge.targetHandle?.startsWith("tgt-")) { | ||
| targetField = edge.targetHandle.slice(4); | ||
| const parsedTarget = parseColumnNameFromHandle(edge.targetHandle); | ||
| targetValid = (targetNode.data.columns || []).some(c => c && c.column_name === parsedTarget); | ||
| if (targetValid) { | ||
| targetField = parsedTarget; | ||
| } | ||
|
Comment on lines
85
to
+92
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 | 🟠 Major | ⚡ Quick win 유효하지 않은 target handle에 유효한
코딩 가이드라인에 따라, 변경된 동작에는 집중 테스트를 추가해야 합니다. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| } else if (edge.targetHandle) { | ||
| targetValid = false; // Present but undecodable | ||
| } | ||
|
|
||
| if (sourceField) { | ||
| if (sourceField && sourceValid && targetValid) { | ||
| const isUnique = sourceNode.data.columns.find(c => c.column_name === sourceField)?.is_pk || false; | ||
|
|
||
| const relList = incomingRelationsByNode.get(edge.target) || []; | ||
|
|
||
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.
🔍 Frontend release note missing
This user-visible export fix updates only the root changelog. Repository conventions also require an entry in the frontend changelog.
Was this helpful? React with 👍 or 👎 to provide feedback.