-
Notifications
You must be signed in to change notification settings - Fork 0
⚡ Bolt: [성능 개선] ERD 내보내기 과정의 O(N*C) 핸들 인코딩 병목 제거 및 Prisma 버그 수정 #983
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
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 |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ export function exportPrisma( | |
| // Prisma relations require a field on both sides if we want back-relations, | ||
| // but let's just generate the minimal required relations. | ||
| const fkNodeColumnPairs = new Set<string>(); | ||
| const fkNodeHandlePairs = new Set<string>(); | ||
| const fkNodesWithoutHandles = new Set<string>(); | ||
| const incomingRelationsByNode = new Map<string, Array<{ relationName: string, sourceModel: string, sourceField: string, isUnique: boolean }>>(); | ||
| const edgesProcessed = new Map<string, { sourceModel: string, targetModel: string, sourceFields: string[], targetFields: string[], relationName: string }>(); | ||
|
|
@@ -67,17 +68,23 @@ export function exportPrisma( | |
| if (!sourceNode || !targetNode) continue; | ||
|
|
||
| const relName = sanitizeName(String(edge.label || `${sourceNode.data.title}_${targetNode.data.title}`)); | ||
| const edgeData = edge.data as { sourceColumns?: string[], targetColumns?: string[] } | undefined; | ||
|
|
||
| let sourceField = ""; | ||
| if (edge.sourceHandle?.startsWith("src-")) { | ||
| sourceField = edge.sourceHandle.slice(4); | ||
| if (edgeData?.sourceColumns?.[0]) { | ||
| sourceField = edgeData.sourceColumns[0]; | ||
| fkNodeColumnPairs.add(`${edge.source}:${sourceField}`); | ||
| } else if (edge.sourceHandle?.startsWith("src-")) { | ||
| sourceField = edge.sourceHandle.slice(4); // Legacy encoded handle | ||
| fkNodeHandlePairs.add(`${edge.source}:${sourceField}`); | ||
| } else if (!edge.sourceHandle) { | ||
| fkNodesWithoutHandles.add(edge.source); | ||
| } | ||
|
|
||
| let targetField = "id"; // fallback | ||
| if (edge.targetHandle?.startsWith("tgt-")) { | ||
| if (edgeData?.targetColumns?.[0]) { | ||
| targetField = edgeData.targetColumns[0]; | ||
| } else if (edge.targetHandle?.startsWith("tgt-")) { | ||
| targetField = edge.targetHandle.slice(4); | ||
| } | ||
|
Comment on lines
+74
to
89
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: Prisma composite FKs reference only the first column For a composite foreign key, Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
|
|
@@ -112,9 +119,12 @@ export function exportPrisma( | |
| for (const col of node.data.columns) { | ||
| const fieldName = sanitizeName(col.column_name); | ||
|
|
||
| const isFk = | ||
| fkNodeColumnPairs.has(`${node.id}:${sanitizeHandleId(col.column_name)}`) || | ||
| (fkNodesWithoutHandles.has(node.id) && node.data.badges?.fk); | ||
| let isFk = fkNodeColumnPairs.has(`${node.id}:${col.column_name}`) || | ||
| (fkNodesWithoutHandles.has(node.id) && node.data.badges?.fk); | ||
|
|
||
| if (!isFk && fkNodeHandlePairs.size > 0) { | ||
| isFk = fkNodeHandlePairs.has(`${node.id}:${sanitizeHandleId(col.column_name)}`); | ||
| } | ||
|
Comment on lines
+122
to
+127
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: Recomputed isFk has no effect in Prisma The recomputed Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
+125
to
+127
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: Prisma tests use raw handles, not real hex-encoded ones
Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| const prismaType = mapToPrismaType(col.data_type, isFk); | ||
|
|
||
|
|
||
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.
🟡 User-visible export change missing CHANGELOG entry
This PR changes Prisma export output — foreign-key reference field names now use real column names instead of hex-encoded handle ids — a user-visible behavior change. Neither
CHANGELOG.mdnorfrontend/CHANGELOG.mdis updated, which the repo conventions require.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.