fix connections leak

This commit is contained in:
李龙 2021-11-03 12:07:21 +08:00
parent 7b927900e9
commit b947dee882

View File

@ -5,7 +5,7 @@ import (
) )
func BeginTransaction(db *gorm.DB) { func BeginTransaction(db *gorm.DB) {
if !db.Config.SkipDefaultTransaction { if !db.Config.SkipDefaultTransaction && db.Error == nil {
if tx := db.Begin(); tx.Error == nil { if tx := db.Begin(); tx.Error == nil {
db.Statement.ConnPool = tx.Statement.ConnPool db.Statement.ConnPool = tx.Statement.ConnPool
db.InstanceSet("gorm:started_transaction", true) db.InstanceSet("gorm:started_transaction", true)