Skip to content

Commit

Permalink
fix(helper): QueryBy()没有实现ctx中断
Browse files Browse the repository at this point in the history
  • Loading branch information
yeaha committed Jun 30, 2023
1 parent 3253d64 commit a4aeddc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func QueryBy(ctx context.Context, db DB, stmt *goqu.SelectDataset, fn func(ctx c
defer rows.Close()

for rows.Next() {
select {
case <-ctx.Done():
return ctx.Err()
default:
}

if err := fn(ctx, rows); err != nil {
return fmt.Errorf("handle row, %w", err)
}
Expand Down

0 comments on commit a4aeddc

Please sign in to comment.