Skip to content
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

Regression in relation field name deduplication #16547

Closed
pimeys opened this issue Nov 30, 2022 · 2 comments · Fixed by prisma/prisma-engines#3468
Closed

Regression in relation field name deduplication #16547

pimeys opened this issue Nov 30, 2022 · 2 comments · Fixed by prisma/prisma-engines#3468
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. team/schema Issue for team Schema. tech/engines/introspection engine Issue in the Introspection Engine topic: relations
Milestone

Comments

@pimeys
Copy link
Contributor

pimeys commented Nov 30, 2022

Bug description

If a relation field would be named in a similar manner as a scalar field in the model, we used to deduplicate it and generate a name that hopefully would not clash with the scalar field in 4.6.0. In version 4.7.0 this feature was removed.

In version 4.6.0 we did:

model A {
  id   Int @id
  b    Int
  aToB B   @relation(fields: [b], references: [id])
}

model B {
  id Int @id
  as A[]
}

And in version 4.7.0 we do:

model A {
  id Int @id
  b  Int
  b  B   @relation(fields: [b], references: [id])
}

model B {
  id Int @id
  as A[]
}

As we can see, in the latter the relation and scalar field are named as b, leading to a validation error.

The PR in culprit that changed the behavior: prisma/prisma-engines#3381

@pimeys pimeys added kind/bug A reported bug. kind/regression A reported bug in functionality that used to work before. tech/engines/introspection engine Issue in the Introspection Engine topic: relations team/schema Issue for team Schema. labels Nov 30, 2022
@pimeys pimeys added this to the 4.8.0 milestone Nov 30, 2022
@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. and removed kind/bug A reported bug. labels Nov 30, 2022
@pimeys pimeys self-assigned this Dec 6, 2022
@tomhoule
Copy link
Contributor

tomhoule commented Dec 6, 2022

Implementation-wise, we can add this to relation_names.rs as an extra condition in which we consider the relation as ambiguous.

@pimeys
Copy link
Contributor Author

pimeys commented Dec 6, 2022

I'm gathering the names of scalar fields in IntrospectionMap now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. team/schema Issue for team Schema. tech/engines/introspection engine Issue in the Introspection Engine topic: relations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants