Prisma nested "Where" with "OR" operator returns nothing

509 Views Asked by At

Adding "OR" inside nested "where" returns nothing.

Removing "OR" inside nested "where" returns the results.

What's the issue?

enter image description here

1

There are 1 best solutions below

0
Mohamed Wael On

The problem might arise from the query value being potentially undefined. Using undefined as a value in a filter essentially tells Prisma Client you have decided not to define a filter for that column. In such cases, each Prisma operator behaves differently when no filters are defined:

  • OR will return empty list.
  • AND return all items.
  • NOT return all items.

By commenting out the OR operator, you effectively applied the AND operator, resulting that returned all items.

For additional details refer to this page: The effect of null and undefined on conditionals