From 7af80ae8a6c42716d3be04914ce77d70eaaaa9fb Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 25 Mar 2023 10:19:08 -0500 Subject: [PATCH] Batch Query callback is called even when there is an error This allows the callback to handle additional error types such as foreign key constraint violations. See https://github.com/jackc/pgx/pull/1538. --- batch.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/batch.go b/batch.go index af62039f..bb22c378 100644 --- a/batch.go +++ b/batch.go @@ -21,13 +21,10 @@ type batchItemFunc func(br BatchResults) error // Query sets fn to be called when the response to qq is received. func (qq *QueuedQuery) Query(fn func(rows Rows) error) { qq.fn = func(br BatchResults) error { - rows, err := br.Query() - if err != nil { - return err - } + rows, _ := br.Query() defer rows.Close() - err = fn(rows) + err := fn(rows) if err != nil { return err }