Comments (6)
I get where you're coming from, and I can genuinely see the perspective from which this makes sense and is reasonable. The only hangups I have are:
- The repository is
prisma-case-format
and notprisma-mapping-linter
, although frankly, maybe it should change, if this is what the users are asking for. - Personally, I don't totally buy the narrative that
schema.prisma
's need a linter, but maybe there are dev workflows out there in which it genuinely is possible to sneak a field name change past peer review. - If we're not using the
'disable'
semantic, it feels like we're essentially signing-in-triplicate: "And sofullName
, son of"first_name_last_name"
, first of his name, shall forever henceforth be known asfullName
, for so twas ordained not only inschema.prisma
but also in the.prisma-case-format
, and he whosoever should try to change it shall be put to death by the CI/CD job in a public square of his choosing..." 😛 like, to my mind, that was the point of theschema.prisma
: to be the source of truth. Although, I know thatprisma
also supports an introspect-oriented database-first approach where migration scripts are the first source of truth and theschema
is a knock-on file.
In the end, I think you're probably right, I just need to mull it over.
from prisma-case-format.
What's your setup?
from prisma-case-format.
I may have miscalculated the next auth default schema
from prisma-case-format.
So, on https://authjs.dev/reference/adapter/prisma at least the latest version shows that expires
is just a DateTime
with no map.
however, you should be able to specify the whole .prisma-case-format
file right now (as discussed in our previous thread), but then for the VerificationToken
model, you can do
override:
...
VerificationToken:
...
expires: 'disable'
I'll work on making it so this works in tandem with --uses-next-auth
so that you don't have to specify everything. Also I spotted some bugs that I need to squash before I merge this all and graduate it from beta.
Thanks for pointing these problems out.
from prisma-case-format.
Right, the @map
isn't required by Auth.js, but that's needed in our case because the DB schema follows a strict convention for date-time columns (they all end with an _at
suffix). We have a few other situations where the fields required by Auth.js/Next-Auth map to a DB column where the name differs from the field name (not only in case) and also require a @map
.
override: ... VerificationToken: ... expires: 'disable'
Thanks, you're right that's an option I didn't consider.
I'm still not sure if it is a good default to remove or overwrite existing @map
for cases where both names differ (by "existing maps" I mean the ones that aren't managed by prisma-case-format
). If I take the following example:
model MyModel {
fullName String @map("first_name_last_name")
}
Here we may have a situation with a DB with a pre-existing column named first_name_last_name
that cannot be changed due to reasons (e.g. other systems already depend on it), but we would prefer to present it as a fullName
field for the generated Prisma client. Ideally prisma-case-format
could still ensure the field name is camelCase and the column name is snake_case, but wouldn't remove or replace the @map
. Or maybe in this situation it may be even safer to completely ignore the @map
case? Not 100% sure.
from prisma-case-format.
I've added the ability for this in the .prisma-case-format
file in v2.2.0
.
override:
MyModel:
field:
fullName: mapField=!first_name_last_name
See docs for more detail
from prisma-case-format.
Related Issues (20)
- `Unsupported` fields are parsed incorrectly HOT 5
- Enums are not mapped HOT 5
- Add a LICENSE file HOT 4
- Ignore Command & Excluding Enums HOT 4
- Any way to keep enums singular when table names are plural? HOT 3
- Broken output for pascal case HOT 4
- New version of package have old content HOT 1
- No @@map created for enums HOT 5
- Possibility to skip some models HOT 23
- Q. How to use this tool ? HOT 8
- Add option to ignore pluralize option per field HOT 8
- [Feature request] Obtain default schema location from package.json
- [Feature request] Enable configuration via package.json HOT 1
- Allow programmatic usage of library (example: vscode formatter extension) HOT 2
- Run Prisma's `formatSchema` before AND after the case formatting to automatically add missing relations HOT 2
- MongoDB ID field issue HOT 4
- Invalid `--uses-next-auth` cli option HOT 1
- Config file does not load before `tryGetFileContents` HOT 2
- Camel case not working as expected for fields with numbers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-case-format.