jest-prisma icon indicating copy to clipboard operation
jest-prisma copied to clipboard

`enableExperimentalRollbackInTransaction` seems not working with MySQL

Open szymon-ludyga opened this issue 1 year ago • 0 comments

Hello,

Really nice library!

Run into an issue with enableExperimentalRollbackInTransaction flag. My environment:

MySQL v8.0.34
Prisma v5.1.1

I'm trying to test the endpoint with the transaction inside and set enableExperimentalRollbackInTransaction = true. However, I get a MySQL 1295 error when entering transaction code in the endpoint during test.

{
  error: PrismaClientKnownRequestError: 
  Invalid `prisma.$executeRawUnsafe()` invocation:
        
        
  Raw query failed. Code: `1295`. Message: `This command is not supported in the prepared statement protocol yet`
    at Hr.handleRequestError (/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:122:6999)
    at Hr.handleAndLogRequestError (/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:122:6388)
    at Hr.request (/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:122:6108)
    at l (/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:126:10298)
    at OfficeService.createOffice (/api/src/services/OfficeService.ts:83:5)
    at Object.<anonymous> (/api/src/tests/Office/createOffice.integration.test.ts:71:7) {
  code: 'P2010',
  clientVersion: '5.1.1',
  meta: {
    code: '1295',
    message: 'This command is not supported in the prepared statement protocol yet'
    }
  }
}

Error points to the code

await parentTxClient.$executeRawUnsafe(`SAVEPOINT ${savePointId};`);

In MySQL, there are docs with SQL Syntax Permitted in Prepared Statements and it seems that SAVEPOINT is not on this list. My guess would be because of that we're not able to run $executeRawUnsafe properly. But maybe I did something wrong in the process. Did you test enableExperimentalRollbackInTransaction also for MySQL database?

szymon-ludyga avatar Aug 21 '23 20:08 szymon-ludyga