Repository navigation
fix(er): keep same-name models apart in Mermaid (#223) - #234
Merged
FROWNINGdev merged 2 commits intoNov 10, 2026
Merged
Conversation
A class name defined in more than one app is written as <app>_<Model>, and relation ends resolve to the model in the field's own app or the app named in the reference. Diagrams without duplicate names are unchanged.
|
Caution Review failedThe pull request is closed.
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. |
Owner
|
Thanks @sarankumar1325. Prefixing only colliding names keeps every other diagram byte-identical, which is what I wanted. Merged. |
4 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mermaid has a single namespace for entity names, so
basket.Lineandorder.Linebecame oneLinebox with both apps' columns, linked to both parents._build_mermaid()now writes a class name that more than one app defines as<app>_<Model>(basket_Line,order_Line). The other names stay bare, so diagrams of projects without duplicate names are byte-identical to before.Relation ends use the same ids. A bare target such as
ForeignKey(Line, ...)resolves to theLinein the field's own app. An app-qualified reference ('order.Line') keeps its app. Anything else falls back to the first one found.'self'points at the model's own entity.I left out the optional alias label (
basket_Line["basket.Line"]) to keep the change small. I'm happy to add it if you want it.Type of change
Test plan
New
MermaidSameNameModelsTestincli/tests/test_er_formats.py:test_colliding_names_get_their_app_prefix: the repro from the issue. Two separatebasket_Line/order_Lineentities, each with only its own columns, and each FK edge starts from its ownLine. Fails on main.test_edges_to_a_colliding_name_pick_the_right_app: covers same-app resolution,'self', and'order.Line'from a third app. Fails on main.test_unique_names_are_unchanged: the entity list for thegolden/saleorfixture is exactly the bare model names.I also ran
_build_mermaidover every fixture directory before and after the change. Each project's output is identical. Only the combinedfixtures/goldenscan changed, becausecms.Pageandwagtail.Pagecollide there.Checklist
cd cli && pytest -qfor Python,npm testfor TypeScript) and it is green## [Unreleased]mcp_server.pyand the relevant tests intest_mcp_server.py## Summaryabove and suggested a migration pathRelated issues / discussions
Closes #223
I wrote this with help from an AI coding assistant, and I reviewed and tested the change myself.