forked from mirror/gorm
Do not panic if Begin().Error was ignored (#1830)
This commit is contained in:
parent
52c5c8127c
commit
919c6db4f8
3
main.go
3
main.go
|
@ -491,7 +491,8 @@ func (s *DB) Begin() *DB {
|
||||||
|
|
||||||
// Commit commit a transaction
|
// Commit commit a transaction
|
||||||
func (s *DB) Commit() *DB {
|
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())
|
s.AddError(db.Commit())
|
||||||
} else {
|
} else {
|
||||||
s.AddError(ErrInvalidTransaction)
|
s.AddError(ErrInvalidTransaction)
|
||||||
|
|
Loading…
Reference in New Issue