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

This commit is contained in:
lrita 2018-05-04 11:55:13 +08:00
parent 9044197ef9
commit 430e1a1860

View File

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