https://www.prisma.io/ logo
#orm-help
Title
# orm-help
m

Michael

09/27/2022, 11:25 PM
is
OR
actually functional? there's no OR present in the generated SQL and instead it seems to be generating the same SQL as when the OR is an AND:
Copy code
await prismaClient.objective.findMany({
      where: {
        patientId: id,
        OR: { // replace with AND makes no difference
          branchingOptionId: { not: null },
          conversationItemId: { not: null },
        },
      },
    });

 // generates: SELECT Objectives.id, ... WHERE (Objectives.patientId = 1 AND Objectives.branchingOptionId IS NOT NULL AND Objectives.conversationItemId IS NOT NULL)
tested in 4.3.1 and 4.4.0, using mysql. Seems to happen for any query with OR in it
1
j

janpio

09/27/2022, 11:47 PM
The docs show it taking an array of filters, not an object: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#or Maybe that makes a difference. (Yours might then be worth a bug report as it should be not validates by the types and query)
m

Michael

09/27/2022, 11:53 PM
dude I stared at that for so long before I posted here and that didn't click
thank you very much! (it works ofc)
this is why I ask before posting issues 😅
I presumed it was structured correctly because typescript wasn't complaining
j

janpio

09/28/2022, 2:46 PM
Yep, and that would be a bug you should report - because that is exactly where Prisma should be able to be helpful of course!
Can you open one? Quickly include your old broken example and waht then actually worked and describe a bit.
m

Michael

09/28/2022, 2:50 PM
An issue for typescript not complaining? Sure thing
j

janpio

09/28/2022, 2:51 PM
(Yep, but in the Prisma issue of course. Not Typescirpt's fault 😄 )
m

Michael

09/28/2022, 2:51 PM
haha yeah 😄
Prisma has been excellent to work with btw, ty so much for all you do
💚 1
😍 1
j

janpio

09/28/2022, 2:58 PM
Thanks!
3 Views