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

Missing @unique attribute is not properly checked #99

Closed
ymc9 opened this issue Nov 17, 2022 · 0 comments
Closed

Missing @unique attribute is not properly checked #99

ymc9 opened this issue Nov 17, 2022 · 0 comments
Milestone

Comments

@ymc9
Copy link
Member

ymc9 commented Nov 17, 2022

One-to-one relation requires one side of reference to be marked @unique. It's not checked today.

repro:

model User {
    id String @id @default(cuid())
    data UserData?
}

model UserData {
    id String @id @default(cuid())
    user User  @relation(fields: [userId], references: [id])
    userId String
}

Error:
Error parsing attribute "@relation": A one-to-one relation must use unique fields on the defining side. Either add an @unique attribute to the field userId, or change the relation to one-to-many.

@ymc9 ymc9 added this to the v0.4.0 milestone Nov 17, 2022
@ymc9 ymc9 added the bug label Nov 17, 2022
@ymc9 ymc9 closed this as completed Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant