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

[PSL] Do not allow references arg on Many2Many relations on SQL #11241

Closed
do4gr opened this issue Jan 18, 2022 · 4 comments · Fixed by prisma/prisma-engines#2947
Closed

[PSL] Do not allow references arg on Many2Many relations on SQL #11241

do4gr opened this issue Jan 18, 2022 · 4 comments · Fixed by prisma/prisma-engines#2947
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema tech/engines Issue for tech Engines. topic: breaking change topic: prisma4 topic: relation-validation
Milestone

Comments

@do4gr
Copy link
Member

do4gr commented Jan 18, 2022

The following datamodel passes validation and is treated as a M:N relation. Its fields and references args though suggest it is a 1:M relation. We should add a validation preventing this confusion and ask the user to either :

  • remove the fields and references args to make clear it is a M:N relation
  • make the email field singular to clarify that it is a 1:M relation

Screen Shot 2022-01-18 at 10 56 51

@pimeys
Copy link
Contributor

pimeys commented Feb 11, 2022

This kind of is semi-done with #11553

So now if you add fields to any side of the relation, it becomes a 2-way embedded m:n and gives a validation error if not using MongoDb. What's still missing is validating against using references in implicit m:n.

@tomhoule
Copy link
Contributor

TBD: we always allowed references as long as it points to the single-field id on the other side. Do we want to forbid it?

@janpio
Copy link
Member

janpio commented Feb 21, 2022

That would really tighten the PSL. It is all we document and support, so there is no benefit in allowing it (besides being laxer in schema creation). @do4gr?

@janpio
Copy link
Member

janpio commented Apr 7, 2022

fields is already disallowed since we introduced embedded m:n for MongoDB. Updated the title to reflect that.

@janpio janpio changed the title [PSL] Do not allow fields and references args on Many2Many relations on SQL [PSL] Do not allow references args on Many2Many relations on SQL Apr 7, 2022
@janpio janpio changed the title [PSL] Do not allow references args on Many2Many relations on SQL [PSL] Do not allow references arg on Many2Many relations on SQL Apr 15, 2022
@janpio janpio modified the milestones: 3.10.0, 4.x May 11, 2022
@pimeys pimeys self-assigned this Jun 1, 2022
mergery bot pushed a commit that referenced this issue Jun 8, 2022
…9742d79d2ca (#13691)

* chore(deps): update engines to 3.16.0-4.151dc9ef4ba65199029dc761667d99742d79d2ca

* test(client): fix fixture schemas, remove references on M:N relations

related #11241

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
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/bug A reported bug. team/schema Issue for team Schema. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema tech/engines Issue for tech Engines. topic: breaking change topic: prisma4 topic: relation-validation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@pimeys @janpio @floelhoeffel @tomhoule @do4gr and others