Skip to content

Commit 54e4a58

Browse files
author
Trevor Atkinson
committed
match sqlc dbtx
1 parent 8e88aec commit 54e4a58

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

dbtx.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,8 @@ func (p *pgxPool) Close(ctx context.Context) error {
5555
}
5656

5757
// Exec implements [Pool].
58-
func (p *pgxPool) Exec(ctx context.Context, sql string, args ...interface{}) (Result, error) {
59-
result, err := p.p.Exec(ctx, sql, args...)
60-
if err != nil {
61-
return nil, err
62-
}
63-
return &pgxResult{
64-
c: result,
65-
}, nil
58+
func (p *pgxPool) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error) {
59+
return p.p.Exec(ctx, sql, args...)
6660
}
6761

6862
// Ping implements [Pool].
@@ -124,12 +118,8 @@ func (p *pgxConn) Ping(ctx context.Context) error {
124118
}
125119

126120
// Exec implements [DBTX].
127-
func (p *pgxConn) Exec(ctx context.Context, stmt string, args ...interface{}) (Result, error) {
128-
result, err := p.c.Exec(ctx, stmt, args...)
129-
if err != nil {
130-
return nil, err
131-
}
132-
return &pgxResult{result}, nil
121+
func (p *pgxConn) Exec(ctx context.Context, stmt string, args ...interface{}) (pgconn.CommandTag, error) {
122+
return p.c.Exec(ctx, stmt, args...)
133123
}
134124

135125
// Query implements [DBTX].

pgx.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55

66
"github.com/jackc/pgx/v5"
7+
"github.com/jackc/pgx/v5/pgconn"
78
)
89

910
type (
1011
// Conn
1112
Conn interface {
12-
Exec(context.Context, string, ...interface{}) (Result, error)
13+
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
1314
QueryRow(context.Context, string, ...interface{}) Row
1415
Query(context.Context, string, ...interface{}) (Rows, error)
1516
}
@@ -33,7 +34,7 @@ type (
3334

3435
Ping(context.Context) error
3536

36-
Exec(context.Context, string, ...interface{}) (Result, error)
37+
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
3738
QueryRow(context.Context, string, ...interface{}) Row
3839
Query(context.Context, string, ...interface{}) (Rows, error)
3940

0 commit comments

Comments
 (0)