Do not panic if Begin().Error was ignored (#1830)

This commit is contained in:
Giuseppe 2018-04-16 16:18:51 +02:00 committed by Jinzhu
parent 52c5c8127c
commit 919c6db4f8
1 changed files with 2 additions and 1 deletions

View File

@ -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)