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
Prisma lift error: ambiguous self-relation detected #488
Comments
Hi, I am unable to reproduce this. The exact steps I took are:
model A {
id String @default(cuid()) @id @unique
name String
related A[]
}
model B {
id String @default(cuid()) @id
name String
test Int
} |
I am able to repro this: https://github.com/divyendu-test/p2-488 Thanks to a nice and shiny debugging session with @momakes |
I am facing same issue, any solution/work around for this? |
@imVinayPandya We will work on this in this sprint 👍 |
After getting this error, is there any way to fall back? |
This should be fixed by prisma/prisma-engines#82 The problem was that we weren't separating between models when validating that relation fields weren't causing any ambiguity, so there were false positives. The fix will be in the next preview :) The PR also contains another change that makes the check for ambiguity in self relationships (model fields that refer to the same model) stricter. Before, with this model: model Human {
id Int @id
parent Human
child Human
} we would have inferred a single self-relation with Now this model is invalid, you need to specify whether you want two self relations or one, by using More info on this change in this schema spec PR: prisma/specs#201 |
Reopening while this is not in alpha 🙏 |
I had the same schema and everything was good, but today after adding some new fields I've started to get this error Here's my schema I tried this |
Both @iaarab and @AbdusamadTurdiev, please both open a new issue and include all the relevant information so that what we can reproduce and later investigate what is going on. (The individual steps how you get your schema, and the schema as text (if possible) would help a lot.) |
is this going to be fixed guys? |
@AbdusamadTurdiev This has been fixed in the engine by prisma/prisma-engines#82 as mentioned by @tomhoule. This hasn't been released yet so we have kept the PR open |
A fix for this was merged to alpha 9 days ago. It will be released as a normal preview tomorrow. |
@mavilein I am still having this issue in |
@nhuesmann : Open a new one please 🙏 |
I accidentally had an error in a data model definition, which lead to a self-referencing model (
related
should have been pointing to a different modelB
, and not toA
):With this data model:
prisma2 lift save/up
was successful.prisma2 lift save/up
failed silently. Debugging showed the error message"Ambiguous self relation detected."
Expected behaviour:
prisma2 lift save/up
, report the"Ambiguous self relation detected."
message, and prevent the creation of the ambiguous self relation.The text was updated successfully, but these errors were encountered: