From 7701c885077051c864da309ed850631ada7d0eea Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 16 Apr 2021 19:27:23 +0800 Subject: [PATCH] Assign transaction error to db --- callbacks/transaction.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/callbacks/transaction.go b/callbacks/transaction.go index 45c6ca11..8ba2ba3b 100644 --- a/callbacks/transaction.go +++ b/callbacks/transaction.go @@ -11,6 +11,8 @@ func BeginTransaction(db *gorm.DB) { db.InstanceSet("gorm:started_transaction", true) } else if tx.Error == gorm.ErrInvalidTransaction { tx.Error = nil + } else { + db.Error = tx.Error } } }