Skip to content

@omit doesn't omit the field when using relationship INCLUDE #984

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

Closed
dikyarga opened this issue Feb 6, 2024 · 2 comments
Closed

@omit doesn't omit the field when using relationship INCLUDE #984

dikyarga opened this issue Feb 6, 2024 · 2 comments
Milestone

Comments

@dikyarga
Copy link
Contributor

dikyarga commented Feb 6, 2024

Description and expected behavior

Background:

I'm following this article: https://zenstack.dev/blog/soft-delete-real to implement soft-delete

Problem

if we get data directly from the model itself db.product.findMany(), it does omit deleted field. But, if we get the data thru include e.g, db.category.findFirst({include: {products: true}}), it doesn't omit the deleted field.

expected behavior

my expectation was to also exclude the field when using relationships.

schema example (simplified):

model Product {
  id String @id @default(cuid())
  category Category @relation(fields: [categoryId], references: [id])
  categoryId String

  deleted Int @default(0) @omit
  @@deny('read', deleted != 0)
}

model Category {
  products Product[]
}

Screenshots
CleanShot 2024-02-06 at 20 43 48@2x

Environment (please complete the following information):

  • ZenStack version: [1.8.1]
  • Prisma version: [5.7.1]
  • Database type: [SQLite]

Additional context

@ymc9
Copy link
Member

ymc9 commented Feb 7, 2024

Thank you for reporting this @dikyarga ! Let me look into it and reply back soon.

@dikyarga
Copy link
Contributor Author

thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants