2
0

Add QueryFunc

refs #821
This commit is contained in:
Jack Christensen
2020-12-12 09:39:58 -06:00
parent 0cbbf55dde
commit e8f959e0e1
7 changed files with 197 additions and 0 deletions
+4
View File
@@ -58,6 +58,10 @@ func (c *Conn) QueryRow(ctx context.Context, sql string, args ...interface{}) pg
return c.Conn().QueryRow(ctx, sql, args...)
}
func (c *Conn) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return c.Conn().QueryFunc(ctx, sql, args, scans, f)
}
func (c *Conn) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
return c.Conn().SendBatch(ctx, b)
}
+10
View File
@@ -430,6 +430,16 @@ func (p *Pool) QueryRow(ctx context.Context, sql string, args ...interface{}) pg
return c.getPoolRow(row)
}
func (p *Pool) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
c, err := p.Acquire(ctx)
if err != nil {
return nil, err
}
defer c.Release()
return c.QueryFunc(ctx, sql, args, scans, f)
}
func (p *Pool) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults {
c, err := p.Acquire(ctx)
if err != nil {
+4
View File
@@ -62,6 +62,10 @@ func (tx *Tx) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx
return tx.t.QueryRow(ctx, sql, args...)
}
func (tx *Tx) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return tx.t.QueryFunc(ctx, sql, args, scans, f)
}
func (tx *Tx) Conn() *pgx.Conn {
return tx.t.Conn()
}