Skip to content

[Bug] future() problems on one-to-one relations #1648

@baenio

Description

@baenio

Description and expected behavior
After trying to create a deny access policy in a schema, I found out, that the policy is not behaving the right way. This issue seems to be related to a one-to-one relation in the schema.

Example

model User {
  id      Int      @id @default(autoincrement())
  profile Profile?
  posts   Post[]
}

model Profile {
  id     Int  @id @default(autoincrement())
  someText String
  user   User @relation(fields: [userId], references: [id])
  userId Int  @unique
}

model Post {
  id     Int    @id @default(autoincrement())
  title  String

  userId String
  user   User   @relation(fields: [userId], references: [id])

  // this will always be true, even if the someText field is "canUpdate"
  @@deny("update", future().user.profile.someText != "canUpdate")

  @@allow("all", true)
}

Environment:

  • ZenStack version: v2.4.1
  • Prisma version: v5.18.0
  • Database type: Postgresql

Additional context
Related Discord thread: https://discord.com/channels/1035538056146595961/1273290058933469225

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions