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.

Home Page:https://zenstack.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Runtime error when disconnecting a self-relation

ymc9 opened this issue · comments

model Category {
    id       Int        @id @default(autoincrement())
    name     String     @unique

    parentId Int?
    parent   Category?  @relation("ParentChildren", fields: [parentId], references: [id])
    children Category[] @relation("ParentChildren")

    @@map('categories')
    @@allow('all', true)
}
const db = ... // enhanced prisma

db.category.update({
  where: {id: 1},  data: { parent: {connect: {id: 1}} }
}) // Works fine to connect

db.category.update({
  where: {id: 1},  data: { parent: {disconnect: true} }
}) // Does not work (?) enhance injects parentId in the where