Repository navigation
Closed
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.topic: errortopic: transaction
Milestone
Description
Bug description
If you attempt to delete a row which does not exist in a transaction, you get a
Error: Error occurred during query execution:
InterpretationError("Error for binding \'0\'", Some(QueryGraphBuilderError(RecordNotFound("Record to delete does not exist."))))
If you attempt the same without transaction, you get a PrismaClientKnownRequestError with a code P2025, which is expected.
How to reproduce
With this code:
try {
const user = await dboClient.user.delete({where: {user_id: '9a535076-59f2-4145-9232-7302d82313d0'}});
console.log(user);
} catch (e) {
console.log(e.toString() + '\n' + JSON.stringify(e));
}Output is the following. Error raised is a PrismaClientKnownRequestError
Error:
Invalid `prisma.user.delete()` invocation:
An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
{"code":"P2025","clientVersion":"2.23.0","meta":{"cause":"Record to delete does not exist."}}
However, if you wrap this in a transaction,
try {
const [,user] = await dboClient.$transaction([
dboClient.user.findUnique({where: {user_id: '9a535076-59f2-4145-9232-7302d82313d0'}}),
dboClient.user.delete({where: {user_id: '9a535076-59f2-4145-9232-7302d82313d0'}})
]);
console.log(user);
} catch (e) {
console.log(e.toString() + '\n' + JSON.stringify(e));
}Output is the following:
Error: Error occurred during query execution:
InterpretationError("Error for binding \'0\'", Some(QueryGraphBuilderError(RecordNotFound("Record to delete does not exist."))))
{"clientVersion":"2.23.0"}
Expected behavior
Even in the transaction, Error should be a PrismaClientKnownRequestError with a code P2025
Prisma information
Schema can be as simple as that
model User {
user_id String @id @db.Uuid @default(dbgenerated("gen_random_uuid()"))
}Environment & setup
- OS: Windows
- Database: PostgreSQL
- Node.js version: v14.16.0
Prisma Version
prisma : 2.23.0
@prisma/client : 2.23.0
Current platform : windows
Query Engine : query-engine adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : adf5e8cba3daf12d456d911d72b6e9418681b28b
Studio : 0.393.0
Reacted by Jan Piotrowski, Selami C and remolueoend
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.topic: errortopic: transaction
Activity
pantharshit00 commentedon Jun 9, 2021
I can reproduce this with
2.25.0-dev.30, we need to check the error handling here.remioo commentedon Jun 18, 2021
janpio commentedon Jun 18, 2021
remioo commentedon Jun 21, 2021