Featured post
Error: Invalid `prisma.$executeRaw()` invocation: fixed using log: ["query"] option
I was using Prisma ORM for my next js project.But when i worked with prisma.$executeRaw() method to update a table in mysql database,i got the Invalid `prisma.$executeRaw()` invocation error as shown below
error - prisma\generated\client\runtime\library.js (163:19498) @ Kr.handleRequestError
Error:
Invalid `prisma.$executeRaw()` invocation:
Raw query failed. Code: `1064`. Message: `You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1`
When i tried to find solution for the Invalid `prisma.$executeRaw()` invocation error,i understood that there can be many reason for the specified error.We need a proper testing method to find the error and fix it.I focused on logging the mysql query to find any error in my mysql query to update the table.In order to log the sql query, i used below codes in defining Prisma client
Normaly it should be
const clientUser = new PrismaClient()
So i changed it to
const clientUser = new PrismaClient({
log: ["query"]
})
It helped me to log the sql query which is going to execute by prisma.$executeRaw() So i could easly find the error Invalid `prisma.$executeRaw()` invocation by checking the log
Now i executed the commands again to run the next js application
npm run build
npm run dev
I could run the project again and i checked the log with the same error Invalid `prisma.$executeRaw()` invocation but at this time on the terminal i had a new line with same error message as shown below
prisma:query ?
prisma:query ?
error - prisma\generated\client\runtime\library.js (163:19498) @ Kr.handleRequestError
Error:
Invalid `prisma.$executeRaw()` invocation:
Raw query failed. Code: `1064`. Message: `You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1`
So ? mark indicates that i am not passing proper query to prisma.$executeRaw() method for insertion or updation.If the sql query was correct it will log something like
prisma:query update user set name ='Technursery' where id=1000
or
prisma:query insert into user(id,name) values(1000,'Technursery')
So i could reach at a conclusion that mysql query to update/insert table in database which is passing to prisma.$executeRaw() method is not correct.So i fixed the error with sql query and i executed prisma.$executeRaw() successfully
Thanks
Popular Posts
How to Check React Version Installed in Your System by Checking PACKAGE.JSON File and Executing Command from COMMAND PROMPT
- Get link
- X
- Other Apps
Execution failed for task ':react-native-reanimated:externalNativeBuildDebug' solved
- Get link
- X
- Other Apps
app keeps stopping error solved in android studio emulator using logcat in react native project
- Get link
- X
- Other Apps
ERROR Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined
- Get link
- X
- Other Apps