Improve error messages for missing back-relation field
See original GitHub issueWith this Prisma schema:
model Event {
id Int @id @default(autoincrement())
owner Person @relation(name: "EventOwners")
recipient Person? @relation(name: "EventRecipients")
}
model Person {
id Int @id @default(autoincrement())
}
I get this error VS Code:
Error validating model "Event": Automatic related field generation would cause a naming conflict. Please add an explicit opposite relation field.
The solution here is fairly straightforward (i.e. adding back-relation fields) but it’s not clear from the error message itself.
An improved error would be a bit more actionable, e.g.:
Please add the opposing relation field on the other model.
Or even (if possibl):
Please add the opposing relation field on the `Person` model.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
django - Display validation errors in the same style as cripsy ...
My problem is that this error message displays at the top of the page as a flash message, while other messages (which i...
Read more >How to Report Errors in Forms: 10 Design Guidelines
1. Aim for Inline Validation Whenever Possible · 2. Indicate Successful Entry for Complex Fields · 3. Keep Error Messages Next to Fields...
Read more >Documentation: 15: 43.9. Errors and Messages - PostgreSQL
Use the RAISE statement to report messages and raise errors. ... If no condition name nor SQLSTATE is specified in a RAISE EXCEPTION...
Read more >Error Messages | Help - Zoho Deluge
The TO field is included in the sendsms task. (Line no: 1) Missing return statement: Provide MAP expression to return. This error message...
Read more >Error Messages: Examples, Best Practices & Common Mistakes
Useful error messages can keep users on your site and increase ... As she said, “the error could be missed or the fields...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Hey @keepforever, Prisma always requires both relation fields to be present per relation. Since you want to create two relations, you need to have two relation fields on each side:
You can find more info in the docs.
To finish this off, my final solution is to reverse the references and store the id on the
User
tables and not theImage
table:My database looks a lot saner:
My query:
returns:
This now looks like the ramblings of a madman but leaving them here to hopefully help anyone coming after.