From a58b98acee2f3bf213b2cb0f1fe1468f236c9aec Mon Sep 17 00:00:00 2001 From: lrita Date: Sat, 12 May 2018 14:28:15 +0800 Subject: [PATCH] Do not panic if Begin().Error was ignored (#1830) (#1881) --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c8a43e8c..25c3a06b 100644 --- a/main.go +++ b/main.go @@ -504,7 +504,8 @@ func (s *DB) Commit() *DB { // Rollback rollback a transaction func (s *DB) Rollback() *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.Rollback()) } else { s.AddError(ErrInvalidTransaction)