how to fix prisma query where 1=1
I have this query
const user = await prisma.user.findFirst({ where: { id: session?.user.id } });
, which seems to translate to
This guarantees that I return an entry even if id is undefined, which I don't want. How do i fix this?12 Replies
it looks like this is also an issue: https://github.com/prisma/prisma/issues/5149 a "design decision"
GitHub
findFirst with
undefined
value shouldn't return data · Issue #514...Bug description Calling findFirst with an undefined in where filter still returns data. This is not intuitive. How to reproduce Deploy this schema with yarn prisma db push --preview-feature datasou...
I think it's fixed now is it? But i don't understand why somebody would make that "design decision"
javascript serialization
Prisma should use Zod in their source code, I stopped trusting JS a long time ago...
why?
problem is js serialization
if you ever talk about superjson, the perf would tank prisma even more
Well there are many the other weird behavior with null/undefined in JS
Prisma is already considered "too slow" many people are jumping on drizzle so, i think adding a couple more packages won't be that bad 😅
50x slower isnt worth for that
plus
superjson is the middleman in the whole process
prisma client calls the prisma rust biding
its just a javascript serialization issue
man it hurts to see that performance hit, even with bun!
Superjson wasn't made to be fast
trpc uses it, i think they have no option