fix connections leak

This commit is contained in:
李龙 2021-11-03 12:38:12 +08:00
parent b947dee882
commit be1494c0cb

View File

@ -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 = queryTx.Find(dest, conds...); queryTx.RowsAffected == 0 {
if tx.Error != nil {
return tx
}
if c, ok := tx.Statement.Clauses["WHERE"]; ok { if c, ok := tx.Statement.Clauses["WHERE"]; ok {
if where, ok := c.Expression.(clause.Where); ok { if where, ok := c.Expression.(clause.Where); ok {
tx.assignInterfacesToValue(where.Exprs) tx.assignInterfacesToValue(where.Exprs)