Skip to content

Commit

Permalink
Rollback on constraint failure
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuddy committed Aug 5, 2022
1 parent 3ccccfb commit 6b59a48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sqlite3.go
Expand Up @@ -494,7 +494,7 @@ func (ai *aggInfo) Done(ctx *C.sqlite3_context) {
// Commit transaction.
func (tx *SQLiteTx) Commit() error {
_, err := tx.c.exec(context.Background(), "COMMIT", nil)
if err != nil && err.(Error).Code == C.SQLITE_BUSY {
if err != nil && (err.(Error).Code == C.SQLITE_BUSY || err.(Error).Code == C.SQLITE_CONSTRAINT) {
// sqlite3 will leave the transaction open in this scenario.
// However, database/sql considers the transaction complete once we
// return from Commit() - we must clean up to honour its semantics.
Expand Down

0 comments on commit 6b59a48

Please sign in to comment.