Bug description
I am trying to use Prisma transactions as specified here. My transaction is not rolling back in case of an error.
Example
const txn1 = this.prisma.table1.create({
data: {
name: `Test 1`
},
});
const txn2 = this.prisma.table1.create({
data: {
name: undefined //`Test 2`,
},
});
const transactionResults = await this.prisma.$transaction([txn1, txn2]);
name is a mandatory column so when I send undefined, txn2 fails but txn1 still creates a record in the table even though it should rollback as txn2 failed.
How to reproduce
Sample code shared above. Try to execute it with a test table.
Expected behavior
Transaction 1 insert should rollback as transaction 2 failed.
Prisma information
Environment & setup
- OS: MacOS Catalina 10.15.1, Running inside docker
node:14.15.4-alpine
- Database: PostgreSQL
- Node.js version: v14.15.4
- Prisma version:
prisma : 2.16.0
@prisma/client : 2.16.0
Current platform : linux-musl
Query Engine : query-engine 854c8ba7f0dce66f115af36af24e66989a8c02a1 (at node_modules/prisma/node_modules/@prisma/engines/query-engine-linux-musl)
Migration Engine : migration-engine-cli 854c8ba7f0dce66f115af36af24e66989a8c02a1 (at node_modules/prisma/node_modules/@prisma/engines/migration-engine-linux-musl)
Introspection Engine : introspection-core 854c8ba7f0dce66f115af36af24e66989a8c02a1 (at node_modules/prisma/node_modules/@prisma/engines/introspection-engine-linux-musl)
Format Binary : prisma-fmt 854c8ba7f0dce66f115af36af24e66989a8c02a1 (at node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-linux-musl)
Studio : 0.346.0
Preview Features : nativeTypes, createMany
Bug description
I am trying to use Prisma transactions as specified here. My transaction is not rolling back in case of an error.
Example
nameis a mandatory column so when I send undefined,txn2fails buttxn1still creates a record in the table even though it should rollback astxn2failed.How to reproduce
Sample code shared above. Try to execute it with a test table.
Expected behavior
Transaction 1 insert should rollback as transaction 2 failed.
Prisma information
Environment & setup
node:14.15.4-alpine