Quramy / jest-prisma

Jest environment for integrated testing with Prisma client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`enableExperimentalRollbackInTransaction` seems not working with MySQL

szymon-ludyga opened this issue · 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/@prisma+client@5.1.1_prisma@5.1.1/node_modules/@prisma/client/runtime/library.js:122:6999)
    at Hr.handleAndLogRequestError (/node_modules/.pnpm/@prisma+client@5.1.1_prisma@5.1.1/node_modules/@prisma/client/runtime/library.js:122:6388)
    at Hr.request (/node_modules/.pnpm/@prisma+client@5.1.1_prisma@5.1.1/node_modules/@prisma/client/runtime/library.js:122:6108)
    at l (/node_modules/.pnpm/@prisma+client@5.1.1_prisma@5.1.1/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?