mirror of https://github.com/jackc/pgx.git
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.pull/1565/head
parent
7555c43033
commit
7af80ae8a6
7
batch.go
7
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.
|
// Query sets fn to be called when the response to qq is received.
|
||||||
func (qq *QueuedQuery) Query(fn func(rows Rows) error) {
|
func (qq *QueuedQuery) Query(fn func(rows Rows) error) {
|
||||||
qq.fn = func(br BatchResults) error {
|
qq.fn = func(br BatchResults) error {
|
||||||
rows, err := br.Query()
|
rows, _ := br.Query()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
err = fn(rows)
|
err := fn(rows)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue