Skip to content

Policy generation error when referencing a boolean field directly in rules #509

Closed
@ymc9

Description

@ymc9
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

model User {
  id Int @id @default(autoincrement())
  email String @unique
  name String?
  posts Post[]
}

model Post {
  id Int @id @default(autoincrement())
  title String
  content String?
  published Boolean @default(false)
  author User? @relation(fields: [authorId], references: [id])
  authorId Int?

  deleted Boolean @default(false) @omit

  @@allow('all', true)
  @@deny('read', deleted)
}
node_modules/.zenstack/policy.ts:5:9 - error TS2304: Cannot find name 'deleted'.

5     if (deleted) { return false; }if (true) { return true; }return false;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions