Skip to content

⚡ Bolt: [성능 개선] ERD 내보내기 과정의 O(N*C) 핸들 인코딩 병목 제거 및 Prisma 버그 수정 - #983

Open
seonghobae wants to merge 1 commit into
mainfrom
bolt-erd-export-optimization-12585343547996245838
Open

⚡ Bolt: [성능 개선] ERD 내보내기 과정의 O(N*C) 핸들 인코딩 병목 제거 및 Prisma 버그 수정#983
seonghobae wants to merge 1 commit into
mainfrom
bolt-erd-export-optimization-12585343547996245838

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

💡 What: Mermaid, Prisma, Data Dictionary 내보내기 시 O(NC) 횟수로 호출되던 sanitizeHandleId 호출을 건너뛰도록 최적화하고 Prisma 내보내기 시 참조 필드명 버그를 수정했습니다.
🎯 Why: 문자열 hex 인코딩이 매 컬럼마다 발생하여 O(N
C) 복잡도로 병목을 일으키고 가비지 컬렉터 부하를 높였습니다.
📊 Impact: 최신 스냅샷(edge.data 활용)에서는 sanitizeHandleId 호출을 완전히 회피하여 ERD 내보내기 성능을 극적으로 향상시키고 Prisma의 외래키 참조 정확도를 보장합니다.
🔬 Measurement: 내보내기 기능이 포함된 frontend/src/erd/export.selfcheck.ts 및 자동화 테스트 환경에서 성능 저하 없이 성공적으로 동작함을 확인합니다.


PR created automatically by Jules for task 12585343547996245838 started by @seonghobae


Open in Devin Review

@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 39 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27e2178d-9345-4090-abde-ffce7daf6b7d

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc7469 and b1bd5ec.

📒 Files selected for processing (4)
  • .jules/bolt.md
  • frontend/src/erd/exportDataDictionary.ts
  • frontend/src/erd/mermaid.ts
  • frontend/src/erd/prisma.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

Open in Devin Review

Comment on lines +74 to 89
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);
}

Copy link
Copy Markdown

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.md nor frontend/CHANGELOG.md is updated, which the repo conventions require.

Prompt for agents
CLAUDE.md and CONTRIBUTING.md require user-visible frontend changes to be recorded in CHANGELOG.md (Korean) and frontend/CHANGELOG.md. This PR changes the Prisma export so foreign-key @relation fields/references use real column names rather than hex-encoded handle ids, and adjusts Mermaid/Data Dictionary FK detection. Add appropriate entries to both CHANGELOG.md and frontend/CHANGELOG.md describing the Prisma FK reference fix and the export performance improvement.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +74 to 89
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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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, exportPrisma uses only sourceColumns[0]/targetColumns[0], so the generated @relation references a single field for a multi-column FK. Not a regression (composite edges previously produced no relation), but the emitted schema for composite FKs stays incomplete.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +122 to +127
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)}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Recomputed isFk has no effect in Prisma

The recomputed isFk is passed to mapToPrismaType, but that function ignores its isFk parameter (prisma.ts:14-39). Relations are driven entirely by edgesProcessed, so this computation is dead. Pre-existing, and unchanged in effect by the diff.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +125 to +127
if (!isFk && fkNodeHandlePairs.size > 0) {
isFk = fkNodeHandlePairs.has(`${node.id}:${sanitizeHandleId(col.column_name)}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Prisma tests use raw handles, not real hex-encoded ones

prisma.test.ts exercises the legacy fallback with raw handles like src-user_id, but convert.ts emits hex-encoded handles (src-c-<hex>) via sourceColumnHandleId. The encoded-handle fallback in Prisma is not covered by a test reflecting real convert output; only the Mermaid FK test at mermaid.test.ts:72 uses an encoded handle.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant