Skip to content

Commit

Permalink
fix(db.ScanRows): ensure rows.Close is called
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonstreator committed Jun 17, 2022
1 parent 7d72761 commit 9ffbc6a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9ffbc6a

Please sign in to comment.