zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

`@id` should imply `@unique` for foreign keys #392

Closed he-la closed 1 year ago

he-la commented 1 year ago

Description and expected behavior

model M1 {
  m2_id    String @id
  m2       M2      @relation(fields: [m2_id], references: [id])
}

model M2 {
  id       String @id

  m1       M1?
}

errors with

Validation errors:
line 68: Value is not assignable to parameter []
line 82: Field "m2_id" is part of a one-to-one relation and must be marked as @unique or be part of a model-level @@unique attribute []

Environment (please complete the following information):

ymc9 commented 1 year ago

Hi @he-la , this issue is resolved by the latest alpha.114 release.

ymc9 commented 1 year ago

Fixed by #400