Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableExperimentalRollbackInTransaction seems not working with MySQL #100

Open
szymon-ludyga opened this issue Aug 21, 2023 · 0 comments
Open

Comments

@szymon-ludyga
Copy link

szymon-ludyga commented Aug 21, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant