Git Product home page Git Product logo

Comments (6)

iiian avatar iiian commented on July 2, 2024 1

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 not prisma-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 so fullName, son of "first_name_last_name", first of his name, shall forever henceforth be known as fullName, for so twas ordained not only in schema.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 the schema.prisma: to be the source of truth. Although, I know that prisma also supports an introspect-oriented database-first approach where migration scripts are the first source of truth and the schema 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.

iiian avatar iiian commented on July 2, 2024

What's your setup?

from prisma-case-format.

iiian avatar iiian commented on July 2, 2024

I may have miscalculated the next auth default schema

from prisma-case-format.

iiian avatar iiian commented on July 2, 2024

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.

dgellow avatar dgellow commented on July 2, 2024

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.

iiian avatar iiian commented on July 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.