From 9ffbc6a46e24b908742b6973f33ef8e5b17cc12b Mon Sep 17 00:00:00 2001 From: DillonStreator Date: Fri, 17 Jun 2022 09:13:19 -0500 Subject: [PATCH] fix(db.ScanRows): ensure rows.Close is called --- db.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db.go b/db.go index 78969c019..0d83c54a4 100644 --- a/db.go +++ b/db.go @@ -141,13 +141,19 @@ func (db *DB) Dialect() schema.Dialect { } func (db *DB) ScanRows(ctx context.Context, rows *sql.Rows, dest ...interface{}) error { + defer rows.Close() + model, err := newModel(db, dest) if err != nil { return err } _, err = model.ScanRows(ctx, rows) - return err + if err != nil { + return err + } + + return rows.Err() } func (db *DB) ScanRow(ctx context.Context, rows *sql.Rows, dest ...interface{}) error {