From 62197e576dcd1509eabab9ac9567d6a63d325688 Mon Sep 17 00:00:00 2001 From: Miguel Moll Date: Mon, 10 Jun 2019 08:12:13 -0400 Subject: [PATCH] Handle error when beginning transaction (#2489) --- scope.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope.go b/scope.go index 4836196a..0e639c70 100644 --- a/scope.go +++ b/scope.go @@ -402,7 +402,7 @@ func (scope *Scope) InstanceGet(name string) (interface{}, bool) { // Begin start a transaction func (scope *Scope) Begin() *Scope { if db, ok := scope.SQLDB().(sqlDb); ok { - if tx, err := db.Begin(); err == nil { + if tx, err := db.Begin(); scope.Err(err) == nil { scope.db.db = interface{}(tx).(SQLCommon) scope.InstanceSet("gorm:started_transaction", true) }