From 3f4e458c093cb193827226aa307647e2f22feadc Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Tue, 14 Feb 2023 11:13:22 -0600 Subject: [PATCH] Nulling out transaction upon commit and rollback --- database/db.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/database/db.go b/database/db.go index 6ba2efb..6bccaa3 100644 --- a/database/db.go +++ b/database/db.go @@ -41,7 +41,9 @@ func (d *DB) CommitTx() error { return errors.New("You have no active db transaction") } if d.commit { - return d.tx.Commit() + err := d.tx.Commit() + d.tx = nil + return err } return nil } @@ -51,7 +53,9 @@ func (d *DB) RollbackTx() error { if d.tx == nil { return errors.New("You have no active db transaction") } - return d.tx.Rollback() + err := d.tx.Rollback() + d.tx = nil + return err } // WillCommit will return the value of commit -- 2.45.2