-
Notifications
You must be signed in to change notification settings - Fork 323
Open
Description
When working with deferred constraints and performing inserts without an explicit transaction, postgres.js fails to properly detect when an error occurs.
// table_name contains DEFERRABLE INITIALLY DEFERRED constraint
// insert *value* object with property which breaks the constraint
await sql`INSERT INTO table_name ${sql(value)}`
// no error, no rejected promise
The error is only properly caught when using an explicit transaction with begin() and performing the insert inside the transaction block.
await sql.begin(async (sql) => {
await sql`INSERT INTO table_name ${sql(value)}`
})
// rejected promise
Metadata
Metadata
Assignees
Labels
No labels