feat: add usePrismaNames option to draw schema names instead of db names - #296
Merged
Conversation
keonik
force-pushed
the
feat/128-name-source
branch
from
August 19, 2026 19:19
e436f10 to
e42a221
Compare
Models and fields with @@Map / @Map are drawn with their database names. usePrismaNames keeps the prisma schema names instead, for models, composite types, enums and fields. Also fixes an @@Map'ed enum rendering twice: the relationship line used the enum's prisma name while the enum block used its database name, so mermaid drew an extra empty node. Entity names on relationship lines are now resolved through the same helper the entity blocks use. Closes #128
keonik
force-pushed
the
feat/128-name-source
branch
from
August 20, 2026 02:20
e42a221 to
a6f5e32
Compare
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.
Closes #128
What
Adds an opt-in
usePrismaNamesgenerator option. By default models and fields carrying@@map/@mapare drawn with their database names; with this option they keep the names as written in the schema.usePrismaNamesfalse(default)usersnick_nametrueUsernickNameCovers models, composite types, enums and fields — per @michaelaltmann's note on the issue that this should apply to columns too.
Drive-by fix:
@@maped enums rendered twiceWhile wiring this up, the entity-name resolution turned out to be inconsistent. The enum block rendered
enum.dbName || enum.name, but the relationship line only searched models/composite types, never enums — so it fell through to the enum's Prisma name:erDiagram roles { ADMIN ADMIN USER USER } "accounts" |o--|| "Role" : "enum:role"Mermaid draws that as an extra empty
Rolenode next to the populatedrolesone. Relationship endpoints now resolve through the samedisplayNamehelper the entity blocks use, so both sayroles.Output change for existing users
For schemas using
@@map, relationship endpoints are now consistently quoted:Mermaid parses both identically — this is the same node, just quoted like every other endpoint already was. Verified against
prisma/mappings.prisma; the rest of the output is byte-identical.Testing
__tests__/usePrismaNames.test.ts— both naming modes plus the enum-node regression. Renders to.mdstraight from the DMMF, so no browser needed.prisma/mappings.prismabefore/after to confirm the default path only changed in the two ways described above.