queryRaw plsql function failed Code: `42601`. Message: `ERROR: syntax error at or near "$1"`
Hi everyone, I'm trying to call a function in my Postgres DB with this signature:
It gets the brand ID as a variable.
Using Prisma I'm not able to call it no matter what I do:
queryRaw
executeRaw
queryRawUnsafe
executeRawUnsafe
(this is in our tests so no fear of SQL injection)
Here is an example:
brand.id
is a UUID string.
I get this error all the time with all approaches:
Even when I use the unsafe approach the error seems to happen in the queryRaw
function (or executeRaw
if I try and use executeRawUnsafe
).
I also tried using Prisma.raw as was suggested in some Github repo and it didn't work: https://github.com/prisma/prisma/issues/13162#issuecomment-1675434494
How can I make it work?
I assumed that I could run everything I wanted with the unsafe
approaches but seems like it's not working.
It is worth mentioning that if I take the SQL string and run it directly on the DB it does work.
Prisma version: 5.22.0
GitHub
Raw query failed. Code:
42601
. Message: `db error: ERROR: syntax ...Bug description const time = 5 await this.prisma.$executeRaw
UPDATE public.user SET chat_banned_time = NOW() + INTERVAL '${time} MINUTES' WHERE id = ${userId}
; PrismaClientKnownRequestEr...3 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai
for a quick spin!I also tried everything mentioned here by the AI:
https://discord.com/channels/937751382725886062/1339147283022876673/1339147286353281034
Tried it all before it suggested it. Still getting the same issue :/
Event this fails with the same issue:
And this with castings:
Hi @Kazaz
Are you still facing issues with this?