summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/stdlib')
-rw-r--r--vendor/github.com/jackc/pgx/v5/stdlib/sql.go30
1 files changed, 9 insertions, 21 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/stdlib/sql.go b/vendor/github.com/jackc/pgx/v5/stdlib/sql.go
index 4924fe41a..939b9636d 100644
--- a/vendor/github.com/jackc/pgx/v5/stdlib/sql.go
+++ b/vendor/github.com/jackc/pgx/v5/stdlib/sql.go
@@ -471,7 +471,8 @@ func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.Nam
return nil, driver.ErrBadConn
}
- args := namedValueToInterface(argsV)
+ args := make([]any, len(argsV))
+ convertNamedArguments(args, argsV)
commandTag, err := c.conn.Exec(ctx, query, args...)
// if we got a network error before we had a chance to send the query, retry
@@ -488,8 +489,9 @@ func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.Na
return nil, driver.ErrBadConn
}
- args := []any{databaseSQLResultFormats}
- args = append(args, namedValueToInterface(argsV)...)
+ args := make([]any, 1+len(argsV))
+ args[0] = databaseSQLResultFormats
+ convertNamedArguments(args[1:], argsV)
rows, err := c.conn.Query(ctx, query, args...)
if err != nil {
@@ -848,28 +850,14 @@ func (r *Rows) Next(dest []driver.Value) error {
return nil
}
-func valueToInterface(argsV []driver.Value) []any {
- args := make([]any, 0, len(argsV))
- for _, v := range argsV {
- if v != nil {
- args = append(args, v.(any))
- } else {
- args = append(args, nil)
- }
- }
- return args
-}
-
-func namedValueToInterface(argsV []driver.NamedValue) []any {
- args := make([]any, 0, len(argsV))
- for _, v := range argsV {
+func convertNamedArguments(args []any, argsV []driver.NamedValue) {
+ for i, v := range argsV {
if v.Value != nil {
- args = append(args, v.Value.(any))
+ args[i] = v.Value.(any)
} else {
- args = append(args, nil)
+ args[i] = nil
}
}
- return args
}
type wrapTx struct {