From 919c6db4f854e4feaae94202ae29da4e3779de49 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Mon, 16 Apr 2018 16:18:51 +0200 Subject: [PATCH] Do not panic if Begin().Error was ignored (#1830) --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c26e05c8..ffee4ec6 100644 --- a/main.go +++ b/main.go @@ -491,7 +491,8 @@ func (s *DB) Begin() *DB { // Commit commit a transaction func (s *DB) Commit() *DB { - if db, ok := s.db.(sqlTx); ok && db != nil { + var emptySQLTx *sql.Tx + if db, ok := s.db.(sqlTx); ok && db != nil && db != emptySQLTx { s.AddError(db.Commit()) } else { s.AddError(ErrInvalidTransaction)