Skip to main content

Featured post

How to Insert line break in Text component in React Native

Hi, I was developing an application in react native.I have to handle lots of text data in this small react native application.I have used  Text component in react native many times. While working on this application,i had a requirement to display some text content with line breaks.I will explain it clearly with an example.I want to display a text as shown below  Welcome Please subscribe my channel I wrote react native code as shown below <View> <Text> Welcome Please subscribe my channel </Text> <View> When i run these lines of code,It will display text as shown below Welcome Please subscribe my channel   - instead of displaying in two lines with line break,it displays in a single line.So i have to find a solution to insert line break in Text component in React Native.After lots of research,i found a clean solution as shown below <View> <Text> Welcome{"\n"} Please subscribe my channel </Text> <View> Here ...

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