question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Casing for Prisma Client model and field names

See original GitHub issue

Similar 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:

image

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
schicklingcommented, Mar 17, 2020

Re-opening as we’ve undone this decision. We’ll have to revisit this.

0reactions
pantharshit00commented, Aug 8, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found