P
Prisma•2w ago
Papa Smerf

Prisma.join throwing error when using edge client

prisma : 5.22.0 @prisma/client : 5.22.0 Node.js : v23.1.0 Next.JS : v15.0.3 Temporary solution (bad): change import { PrismaClient } from "@prisma/client/edge"; to import { PrismaClient } from "@prisma/client"; When i tried to use Prisma.join() on raw query using edge client i got an error: TypeError: The "payload" argument must be of type object. Received null Example query:
await prisma.$queryRaw`
SELECT "id" FROM "table"
WHERE "x" = ${String(query)}
AND "y" = ${String(query1)}
AND "z" IN (${Prisma.join(stringsArray)})
AND "i" IN (${Prisma.join(stringsArray)})
AND "j" IN (${Prisma.join(stringsArray)})
LIMIT ${number}`
await prisma.$queryRaw`
SELECT "id" FROM "table"
WHERE "x" = ${String(query)}
AND "y" = ${String(query1)}
AND "z" IN (${Prisma.join(stringsArray)})
AND "i" IN (${Prisma.join(stringsArray)})
AND "j" IN (${Prisma.join(stringsArray)})
LIMIT ${number}`
Any idea how to make it work on edge?
Solution:
Hi @Papa Smerf The edge client is a stripped down version and may not support the Prisma.join() api. Rewriting the raw query without using Prisma.join() should resolve this issue. `` await prisma.$queryRaw...
Jump to solution
3 Replies
Solution
RaphaelEtim
RaphaelEtim•2w ago
Hi @Papa Smerf The edge client is a stripped down version and may not support the Prisma.join() api. Rewriting the raw query without using Prisma.join() should resolve this issue.
await prisma.$queryRaw`
SELECT "id" FROM "table"
WHERE "x" = ${String(query)}
AND "y" = ${String(query1)}
AND "z" = ANY(${stringsArray}::text[])
AND "i" = ANY(${stringsArray}::text[])
AND "j" = ANY(${stringsArray}::text[])
LIMIT ${number}
await prisma.$queryRaw`
SELECT "id" FROM "table"
WHERE "x" = ${String(query)}
AND "y" = ${String(query1)}
AND "z" = ANY(${stringsArray}::text[])
AND "i" = ANY(${stringsArray}::text[])
AND "j" = ANY(${stringsArray}::text[])
LIMIT ${number}
The raw query example assumes you are using Postgres. Let me know if this helps.
Papa Smerf
Papa SmerfOP•2w ago
Yep it works. Thank you!
RaphaelEtim
RaphaelEtim•2w ago
I'm glad to hear it works 🎉
Want results from more Discord servers?
Add your server