Skip to content

Commit 6b59a48

Browse files
committed
Rollback on constraint failure
1 parent 3ccccfb commit 6b59a48

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sqlite3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ func (ai *aggInfo) Done(ctx *C.sqlite3_context) {
494494
// Commit transaction.
495495
func (tx *SQLiteTx) Commit() error {
496496
_, err := tx.c.exec(context.Background(), "COMMIT", nil)
497-
if err != nil && err.(Error).Code == C.SQLITE_BUSY {
497+
if err != nil && (err.(Error).Code == C.SQLITE_BUSY || err.(Error).Code == C.SQLITE_CONSTRAINT) {
498498
// sqlite3 will leave the transaction open in this scenario.
499499
// However, database/sql considers the transaction complete once we
500500
// return from Commit() - we must clean up to honour its semantics.

0 commit comments

Comments
 (0)