Casing for Prisma Client model and field names
See original GitHub issueSimilar to https://github.com/prisma/prisma2/issues/1851, but Client level
Upper case models produce Prisma client call with a weird casing:
model ATOMS { ATOM_TYPE Int? CHARGE Float? ELEMENT String? ID Int @default(0) @id DRUG_ID DRUGS? bONDS_ATOMSToBONDS_ATOM1_ID BONDS[] @relation("ATOMSToBONDS_ATOM1_ID") bONDS_ATOMSToBONDS_ATOM2_ID BONDS[] @relation("ATOMSToBONDS_ATOM2_ID") rING_ATOM RING_ATOM[] @@index([DRUG_ID], name: "ATOMS_DRUG_ID") }
Casing in generated client:
Same applies for field names like
bONDS_ATOMSToBONDS_ATOM1_ID
.
Right now this exists: https://github.com/prisma/prisma-client-js/blob/ffa2f18bd5dc9390380f01d3f68a9c81adeb1086/packages/photon/src/runtime/getPrismaClient.ts#L349
This should be removed, and everything that is similar: The schema is the source of truth for capitalization of model and field names.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Using custom model and field names (Concepts) - Prisma
You can "rename" fields and models that are used in the Prisma Client by mapping them to the "original" names in the database...
Read more >Names in the underlying database - Prisma
The Prisma schema includes mechanisms that allow you to define names of certain database objects. You can: Map model and field names to...
Read more >Data model (Reference) - Prisma
Learn about the concepts for building your data model with Prisma: Models, scalar types, enums, attributes, functions, IDs, default values and more.
Read more >Case sensitivity (Reference) - Prisma
How Prisma Client handles case sensitivity when filtering and sorting. ... name: true, ... use the mode: 'insensitive' property on a per-field basis....
Read more >Prisma Client extensions: model component (Preview)
Extend the functionality of Prisma Client, model component. ... '<name>', // `name` is an optional field that you can use to name the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Re-opening as we’ve undone this decision. We’ll have to revisit this.
As I already told here we can’t change it. Here is the lowercase function we use: https://github.com/prisma/prisma/blob/ba74c81fdbc9e6405946fdc6f9d42d103d008dc2/packages/client/src/runtime/utils/common.ts#L452-L455
It is very simple and just lowercase the first letter. It is designed so that generally convention of using Capitalized Case in Prisma schema reflects fine in the client. When you use existing database models we recommend using
@map
if your model doesn’t follow the capitalize case.Changing the lowercase function also means a breaking change for all users.