Reputation: 2244
I am building a node app using node's pg client, and since it's a simple app I am not using app validations and resorting only to postgres constraints to protect data integrity and display insert and update errors.
Using the pg client I only get one constraint violation at once even though multiple violations occur.
Is it possible to set postgres to emit all constrait violations on an insert error?
Upvotes: 4
Views: 1541
Reputation: 324385
Is it possible to set postgres to emit all constrait violations on an insert error?
Not with PostgreSQL, no, because the first violation throws an error that aborts the transaction.
Making PostgreSQL emit all violations would involve major surgery to the core PostgreSQL engine.
Validate in-app to provide user-friendly error messages and guidance; use database constraints and validations to enforce data integrity.
Upvotes: 6