From be1494c0cb2a340f4bacd6c5b72fba594715a8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=BE=99?= Date: Wed, 3 Nov 2021 12:38:12 +0800 Subject: [PATCH] fix connections leak --- finisher_api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/finisher_api.go b/finisher_api.go index 48eb94c5..497dabd5 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -287,6 +287,9 @@ func (db *DB) FirstOrCreate(dest interface{}, conds ...interface{}) (tx *DB) { }) if tx = queryTx.Find(dest, conds...); queryTx.RowsAffected == 0 { + if tx.Error != nil { + return tx + } if c, ok := tx.Statement.Clauses["WHERE"]; ok { if where, ok := c.Expression.(clause.Where); ok { tx.assignInterfacesToValue(where.Exprs)