Postgres: Deleting a record that doesn't exist gives a bad error
See original GitHub issueProblem
The error we get back from bigserial
ids it not very nice.
await prisma.types.delete({
where: {
bigserial: "non-existent id",
},
})
PrismaClientKnownRequestError2:
Invalid `prisma.types.delete()` invocation in
/Users/m/Go/src/github.com/prisma/qa-native-types/index.ts:72:30
68 // },
69 // })
70
71 console.log(
→ 72 await prisma.types.delete(
Query interpretation error. Error for binding '0': RecordNotFound("Record to delete does not exist.")
at PrismaClientFetcher.request (/Users/m/Go/src/github.com/prisma/qa-native-types/node_modules/@prisma/client/runtime/index.js:15871:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
code: 'P2016',
clientVersion: '2.10.0-dev.58',
meta: {
details: `Error for binding '0': RecordNotFound("Record to delete does not exist.")`
}
}
Suggested Solution
Remove Query interpretation error. Error for binding '0':
Issue Analytics
- State:
- Created 3 years ago
- Reactions:22
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Deleting with NOT EXISTS vs NOT IN gives different results
When I check the records deleted by #1 they really do not exist in either house or office . postgresql · Share.
Read more >delete "column does not exist" - Stack Overflow
I'm trying to execute a very simple delete query in Postgres. Query: delete ...
Read more >Documentation: 15: DELETE - PostgreSQL
DELETE deletes rows that satisfy the WHERE clause from the specified table. If the WHERE clause is absent, the effect is to delete...
Read more >Troubleshooting migration tasks in AWS Database Migration ...
To restart your task and avoid these errors, remove rows inserted into the ... In FULL LOB or LIMITED LOB mode, AWS DMS...
Read more >PostgreSQL column does not exist | Definition and Syntax
PostgreSQL column does not exist exception occurs when we have used column did not exist in the table or it will occur when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have this issue as well,
deleteIfExists
?It would be great to have something akin to the following for
delete()
:The current behavior makes things hard to deal with when trying to write idempotent functions for handling Stripe webhooks etc.
While using
deleteMany()
is a decent workaround it doesn’t work in cases such as the below:Something akin to the following would be handy as well: