-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disambiguating relations incorrectly auto formatting #24132
Comments
Some of your suggestion loose the optionality via |
@Ivor808 #18599, that you linked to, is essentially a bug report for what I wrote above:
Fixing this should at least partially improve scenarios 2 and 4. |
Yes. That is a good summary |
Good catch, it was a "manual change that just snuck in" I have fixed the examples |
Yep in general, it should act how defining foreign keys in SQL does. AKA we define the foreign key and unique naming, and format is responsible for propagating that onto the referenced table. In the case of posts, the user is responsible for adding and naming each relation. Format can take those and put them onto the referenced table with the correct naming. Note: The relation naming can be the same it looks like (reference the model below). I checked, and the relation name is just used to generate the FK name on the original table (in this case brand and listing application). So maybe format takes the model name and appends it to the relation name in the parent model (in this case user).
|
Bug description
When creating a model that has disambiguous relations with a relational db the formatter
prisma format
will generate the@relation(fields: [authorId], references: [id])
automatically for each field, but it will not automatically add the name argument.See below for examples. Scenario 3 is how I normally make prisma files
How to reproduce
Scenario 1:
currently generates:
Scenario 2:
currently generates:
Scenario 3:
currently generates:
Scenario 4:
currently generates:
Expected behavior
Scenario 1:
Scenario 2:
Scenario 3:
Scenario 4:
Prisma information
included in previous sections
Environment & setup
Prisma Version
Sorry for the long post.
The text was updated successfully, but these errors were encountered: