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

Validation error points to an invalid location in the PSL #9219

Closed
pimeys opened this issue Sep 13, 2021 · 0 comments · Fixed by prisma/prisma-engines#2218
Closed

Validation error points to an invalid location in the PSL #9219

pimeys opened this issue Sep 13, 2021 · 0 comments · Fixed by prisma/prisma-engines#2218
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: namedConstraints
Milestone

Comments

@pimeys
Copy link
Contributor

pimeys commented Sep 13, 2021

Bug description

When having multiple relation constraints with the same name, the validation error points to a wrong location.

How to reproduce

With the following data model:

datasource db {
  provider = "sqlserver"
  url      = "sqlserver://"
}

model A {
  id  Int @id @default(autoincrement())
  bs1 B[] @relation("A1")
  bs2 B[] @relation("A2")
}

model B {
  id  Int @id @default(autoincrement())
  aId Int
  a1  A   @relation("A1", fields: [aId], references: [id], onUpdate: NoAction)
  a2  A   @relation("A2", fields: [aId], references: [id], onUpdate: NoAction)
}

We get validation errors:

Error: error: Error parsing attribute "@relation": Given constraint name is already in use in the data model.
  -->  schema.prisma:1
   | 
   | 
 1 | datasource chinook {
   | ^ Unexpected token.
   | 
error: Error parsing attribute "@relation": Given constraint name is already in use in the data model.
  -->  schema.prisma:1
   | 
   | 
 1 | datasource chinook {
   | ^ Unexpected token.
   | 

Expected behavior

We should point the field or if possible, the map attribute in the field. We should also print the name of the constraint.

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. topic: namedConstraints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant