2
0

Replace interface{} with any

This commit is contained in:
Jack Christensen
2022-04-09 09:12:55 -05:00
parent 95265a7421
commit f14fb3d692
106 changed files with 1045 additions and 1045 deletions
+10 -10
View File
@@ -10,7 +10,7 @@ import (
type batchItem struct { type batchItem struct {
query string query string
arguments []interface{} arguments []any
} }
// Batch queries are a way of bundling multiple queries together to avoid // Batch queries are a way of bundling multiple queries together to avoid
@@ -20,7 +20,7 @@ type Batch struct {
} }
// Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement. // Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement.
func (b *Batch) Queue(query string, arguments ...interface{}) { func (b *Batch) Queue(query string, arguments ...any) {
b.items = append(b.items, &batchItem{ b.items = append(b.items, &batchItem{
query: query, query: query,
arguments: arguments, arguments: arguments,
@@ -43,7 +43,7 @@ type BatchResults interface {
QueryRow() Row QueryRow() Row
// QueryFunc reads the results from the next query in the batch as if the query has been sent with Conn.QueryFunc. // QueryFunc reads the results from the next query in the batch as if the query has been sent with Conn.QueryFunc.
QueryFunc(scans []interface{}, f func(QueryFuncRow) error) (pgconn.CommandTag, error) QueryFunc(scans []any, f func(QueryFuncRow) error) (pgconn.CommandTag, error)
// Close closes the batch operation. This must be called before the underlying connection can be used again. Any error // Close closes the batch operation. This must be called before the underlying connection can be used again. Any error
// that occurred during a batch operation may have made it impossible to resyncronize the connection with the server. // that occurred during a batch operation may have made it impossible to resyncronize the connection with the server.
@@ -78,7 +78,7 @@ func (br *batchResults) Exec() (pgconn.CommandTag, error) {
err = errors.New("no result") err = errors.New("no result")
} }
if br.conn.shouldLog(LogLevelError) { if br.conn.shouldLog(LogLevelError) {
br.conn.log(br.ctx, LogLevelError, "BatchResult.Exec", map[string]interface{}{ br.conn.log(br.ctx, LogLevelError, "BatchResult.Exec", map[string]any{
"sql": query, "sql": query,
"args": logQueryArgs(arguments), "args": logQueryArgs(arguments),
"err": err, "err": err,
@@ -91,14 +91,14 @@ func (br *batchResults) Exec() (pgconn.CommandTag, error) {
if err != nil { if err != nil {
if br.conn.shouldLog(LogLevelError) { if br.conn.shouldLog(LogLevelError) {
br.conn.log(br.ctx, LogLevelError, "BatchResult.Exec", map[string]interface{}{ br.conn.log(br.ctx, LogLevelError, "BatchResult.Exec", map[string]any{
"sql": query, "sql": query,
"args": logQueryArgs(arguments), "args": logQueryArgs(arguments),
"err": err, "err": err,
}) })
} }
} else if br.conn.shouldLog(LogLevelInfo) { } else if br.conn.shouldLog(LogLevelInfo) {
br.conn.log(br.ctx, LogLevelInfo, "BatchResult.Exec", map[string]interface{}{ br.conn.log(br.ctx, LogLevelInfo, "BatchResult.Exec", map[string]any{
"sql": query, "sql": query,
"args": logQueryArgs(arguments), "args": logQueryArgs(arguments),
"commandTag": commandTag, "commandTag": commandTag,
@@ -134,7 +134,7 @@ func (br *batchResults) Query() (Rows, error) {
rows.closed = true rows.closed = true
if br.conn.shouldLog(LogLevelError) { if br.conn.shouldLog(LogLevelError) {
br.conn.log(br.ctx, LogLevelError, "BatchResult.Query", map[string]interface{}{ br.conn.log(br.ctx, LogLevelError, "BatchResult.Query", map[string]any{
"sql": query, "sql": query,
"args": logQueryArgs(arguments), "args": logQueryArgs(arguments),
"err": rows.err, "err": rows.err,
@@ -149,7 +149,7 @@ func (br *batchResults) Query() (Rows, error) {
} }
// QueryFunc reads the results from the next query in the batch as if the query has been sent with Conn.QueryFunc. // QueryFunc reads the results from the next query in the batch as if the query has been sent with Conn.QueryFunc.
func (br *batchResults) QueryFunc(scans []interface{}, f func(QueryFuncRow) error) (pgconn.CommandTag, error) { func (br *batchResults) QueryFunc(scans []any, f func(QueryFuncRow) error) (pgconn.CommandTag, error) {
if br.closed { if br.closed {
return pgconn.CommandTag{}, fmt.Errorf("batch already closed") return pgconn.CommandTag{}, fmt.Errorf("batch already closed")
} }
@@ -206,7 +206,7 @@ func (br *batchResults) Close() error {
} }
if br.conn.shouldLog(LogLevelInfo) { if br.conn.shouldLog(LogLevelInfo) {
br.conn.log(br.ctx, LogLevelInfo, "BatchResult.Close", map[string]interface{}{ br.conn.log(br.ctx, LogLevelInfo, "BatchResult.Close", map[string]any{
"sql": query, "sql": query,
"args": logQueryArgs(args), "args": logQueryArgs(args),
}) })
@@ -216,7 +216,7 @@ func (br *batchResults) Close() error {
return br.mrr.Close() return br.mrr.Close()
} }
func (br *batchResults) nextQueryAndArgs() (query string, args []interface{}, ok bool) { func (br *batchResults) nextQueryAndArgs() (query string, args []any, ok bool) {
if br.b != nil && br.ix < len(br.b.items) { if br.b != nil && br.ix < len(br.b.items) {
bi := br.b.items[br.ix] bi := br.b.items[br.ix]
query = bi.query query = bi.query
+1 -1
View File
@@ -108,7 +108,7 @@ func TestConnSendBatch(t *testing.T) {
} }
rowCount = 0 rowCount = 0
_, err = br.QueryFunc([]interface{}{&id, &description, &amount}, func(pgx.QueryFuncRow) error { _, err = br.QueryFunc([]any{&id, &description, &amount}, func(pgx.QueryFuncRow) error {
if id != selectFromLedgerExpectedRows[rowCount].id { if id != selectFromLedgerExpectedRows[rowCount].id {
t.Errorf("id => %v, want %v", id, selectFromLedgerExpectedRows[rowCount].id) t.Errorf("id => %v, want %v", id, selectFromLedgerExpectedRows[rowCount].id)
} }
+6 -6
View File
@@ -278,7 +278,7 @@ func BenchmarkSelectWithoutLogging(b *testing.B) {
type discardLogger struct{} type discardLogger struct{}
func (dl discardLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{}) { func (dl discardLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]any) {
} }
func BenchmarkSelectWithLoggingTraceDiscard(b *testing.B) { func BenchmarkSelectWithLoggingTraceDiscard(b *testing.B) {
@@ -438,7 +438,7 @@ const benchmarkWriteTableInsertSQL = `insert into t(
type benchmarkWriteTableCopyFromSrc struct { type benchmarkWriteTableCopyFromSrc struct {
count int count int
idx int idx int
row []interface{} row []any
} }
func (s *benchmarkWriteTableCopyFromSrc) Next() bool { func (s *benchmarkWriteTableCopyFromSrc) Next() bool {
@@ -446,7 +446,7 @@ func (s *benchmarkWriteTableCopyFromSrc) Next() bool {
return s.idx < s.count return s.idx < s.count
} }
func (s *benchmarkWriteTableCopyFromSrc) Values() ([]interface{}, error) { func (s *benchmarkWriteTableCopyFromSrc) Values() ([]any, error) {
return s.row, nil return s.row, nil
} }
@@ -457,7 +457,7 @@ func (s *benchmarkWriteTableCopyFromSrc) Err() error {
func newBenchmarkWriteTableCopyFromSrc(count int) pgx.CopyFromSource { func newBenchmarkWriteTableCopyFromSrc(count int) pgx.CopyFromSource {
return &benchmarkWriteTableCopyFromSrc{ return &benchmarkWriteTableCopyFromSrc{
count: count, count: count,
row: []interface{}{ row: []any{
"varchar_1", "varchar_1",
"varchar_2", "varchar_2",
&pgtype.Text{}, &pgtype.Text{},
@@ -509,9 +509,9 @@ func benchmarkWriteNRowsViaInsert(b *testing.B, n int) {
} }
} }
type queryArgs []interface{} type queryArgs []any
func (qa *queryArgs) Append(v interface{}) string { func (qa *queryArgs) Append(v any) string {
*qa = append(*qa, v) *qa = append(*qa, v)
return "$" + strconv.Itoa(len(*qa)) return "$" + strconv.Itoa(len(*qa))
} }
+25 -25
View File
@@ -216,17 +216,17 @@ func connect(ctx context.Context, config *ConnConfig) (c *Conn, err error) {
config.Config.OnNotification = c.bufferNotifications config.Config.OnNotification = c.bufferNotifications
} else { } else {
if c.shouldLog(LogLevelDebug) { if c.shouldLog(LogLevelDebug) {
c.log(ctx, LogLevelDebug, "pgx notification handler disabled by application supplied OnNotification", map[string]interface{}{"host": config.Config.Host}) c.log(ctx, LogLevelDebug, "pgx notification handler disabled by application supplied OnNotification", map[string]any{"host": config.Config.Host})
} }
} }
if c.shouldLog(LogLevelInfo) { if c.shouldLog(LogLevelInfo) {
c.log(ctx, LogLevelInfo, "Dialing PostgreSQL server", map[string]interface{}{"host": config.Config.Host}) c.log(ctx, LogLevelInfo, "Dialing PostgreSQL server", map[string]any{"host": config.Config.Host})
} }
c.pgConn, err = pgconn.ConnectConfig(ctx, &config.Config) c.pgConn, err = pgconn.ConnectConfig(ctx, &config.Config)
if err != nil { if err != nil {
if c.shouldLog(LogLevelError) { if c.shouldLog(LogLevelError) {
c.log(ctx, LogLevelError, "connect failed", map[string]interface{}{"err": err}) c.log(ctx, LogLevelError, "connect failed", map[string]any{"err": err})
} }
return nil, err return nil, err
} }
@@ -278,7 +278,7 @@ func (c *Conn) Prepare(ctx context.Context, name, sql string) (sd *pgconn.Statem
if c.shouldLog(LogLevelError) { if c.shouldLog(LogLevelError) {
defer func() { defer func() {
if err != nil { if err != nil {
c.log(ctx, LogLevelError, "Prepare failed", map[string]interface{}{"err": err, "name": name, "sql": sql}) c.log(ctx, LogLevelError, "Prepare failed", map[string]any{"err": err, "name": name, "sql": sql})
} }
}() }()
} }
@@ -345,9 +345,9 @@ func (c *Conn) shouldLog(lvl LogLevel) bool {
return c.logger != nil && c.logLevel >= lvl return c.logger != nil && c.logLevel >= lvl
} }
func (c *Conn) log(ctx context.Context, lvl LogLevel, msg string, data map[string]interface{}) { func (c *Conn) log(ctx context.Context, lvl LogLevel, msg string, data map[string]any) {
if data == nil { if data == nil {
data = map[string]interface{}{} data = map[string]any{}
} }
if c.pgConn != nil && c.pgConn.PID() != 0 { if c.pgConn != nil && c.pgConn.PID() != 0 {
data["pid"] = c.pgConn.PID() data["pid"] = c.pgConn.PID()
@@ -382,26 +382,26 @@ func (c *Conn) Config() *ConnConfig { return c.config.Copy() }
// Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced // Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced
// positionally from the sql string as $1, $2, etc. // positionally from the sql string as $1, $2, etc.
func (c *Conn) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) { func (c *Conn) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) {
startTime := time.Now() startTime := time.Now()
commandTag, err := c.exec(ctx, sql, arguments...) commandTag, err := c.exec(ctx, sql, arguments...)
if err != nil { if err != nil {
if c.shouldLog(LogLevelError) { if c.shouldLog(LogLevelError) {
c.log(ctx, LogLevelError, "Exec", map[string]interface{}{"sql": sql, "args": logQueryArgs(arguments), "err": err}) c.log(ctx, LogLevelError, "Exec", map[string]any{"sql": sql, "args": logQueryArgs(arguments), "err": err})
} }
return commandTag, err return commandTag, err
} }
if c.shouldLog(LogLevelInfo) { if c.shouldLog(LogLevelInfo) {
endTime := time.Now() endTime := time.Now()
c.log(ctx, LogLevelInfo, "Exec", map[string]interface{}{"sql": sql, "args": logQueryArgs(arguments), "time": endTime.Sub(startTime), "commandTag": commandTag}) c.log(ctx, LogLevelInfo, "Exec", map[string]any{"sql": sql, "args": logQueryArgs(arguments), "time": endTime.Sub(startTime), "commandTag": commandTag})
} }
return commandTag, err return commandTag, err
} }
func (c *Conn) exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error) { func (c *Conn) exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error) {
mode := c.config.DefaultQueryExecMode mode := c.config.DefaultQueryExecMode
optionLoop: optionLoop:
@@ -460,7 +460,7 @@ optionLoop:
} }
} }
func (c *Conn) execSimpleProtocol(ctx context.Context, sql string, arguments []interface{}) (commandTag pgconn.CommandTag, err error) { func (c *Conn) execSimpleProtocol(ctx context.Context, sql string, arguments []any) (commandTag pgconn.CommandTag, err error) {
if len(arguments) > 0 { if len(arguments) > 0 {
sql, err = c.sanitizeForSimpleQuery(sql, arguments...) sql, err = c.sanitizeForSimpleQuery(sql, arguments...)
if err != nil { if err != nil {
@@ -476,7 +476,7 @@ func (c *Conn) execSimpleProtocol(ctx context.Context, sql string, arguments []i
return commandTag, err return commandTag, err
} }
func (c *Conn) execParamsAndPreparedPrefix(sd *pgconn.StatementDescription, args []interface{}) error { func (c *Conn) execParamsAndPreparedPrefix(sd *pgconn.StatementDescription, args []any) error {
if len(sd.ParamOIDs) != len(args) { if len(sd.ParamOIDs) != len(args) {
return fmt.Errorf("expected %d arguments, got %d", len(sd.ParamOIDs), len(args)) return fmt.Errorf("expected %d arguments, got %d", len(sd.ParamOIDs), len(args))
} }
@@ -500,7 +500,7 @@ func (c *Conn) execParamsAndPreparedPrefix(sd *pgconn.StatementDescription, args
return nil return nil
} }
func (c *Conn) execParams(ctx context.Context, sd *pgconn.StatementDescription, arguments []interface{}) (pgconn.CommandTag, error) { func (c *Conn) execParams(ctx context.Context, sd *pgconn.StatementDescription, arguments []any) (pgconn.CommandTag, error) {
err := c.execParamsAndPreparedPrefix(sd, arguments) err := c.execParamsAndPreparedPrefix(sd, arguments)
if err != nil { if err != nil {
return pgconn.CommandTag{}, err return pgconn.CommandTag{}, err
@@ -511,7 +511,7 @@ func (c *Conn) execParams(ctx context.Context, sd *pgconn.StatementDescription,
return result.CommandTag, result.Err return result.CommandTag, result.Err
} }
func (c *Conn) execPrepared(ctx context.Context, sd *pgconn.StatementDescription, arguments []interface{}) (pgconn.CommandTag, error) { func (c *Conn) execPrepared(ctx context.Context, sd *pgconn.StatementDescription, arguments []any) (pgconn.CommandTag, error) {
err := c.execParamsAndPreparedPrefix(sd, arguments) err := c.execParamsAndPreparedPrefix(sd, arguments)
if err != nil { if err != nil {
return pgconn.CommandTag{}, err return pgconn.CommandTag{}, err
@@ -523,14 +523,14 @@ func (c *Conn) execPrepared(ctx context.Context, sd *pgconn.StatementDescription
} }
type unknownArgumentTypeQueryExecModeExecError struct { type unknownArgumentTypeQueryExecModeExecError struct {
arg interface{} arg any
} }
func (e *unknownArgumentTypeQueryExecModeExecError) Error() string { func (e *unknownArgumentTypeQueryExecModeExecError) Error() string {
return fmt.Sprintf("cannot use unregistered type %T as query argument in QueryExecModeExec", e.arg) return fmt.Sprintf("cannot use unregistered type %T as query argument in QueryExecModeExec", e.arg)
} }
func (c *Conn) execSQLParams(ctx context.Context, sql string, args []interface{}) (pgconn.CommandTag, error) { func (c *Conn) execSQLParams(ctx context.Context, sql string, args []any) (pgconn.CommandTag, error) {
c.eqb.Reset() c.eqb.Reset()
anynil.NormalizeSlice(args) anynil.NormalizeSlice(args)
@@ -557,7 +557,7 @@ func (c *Conn) execSQLParams(ctx context.Context, sql string, args []interface{}
// //
// Given that the whole point of QueryExecModeExec is to operate without having to know the PostgreSQL types there is // Given that the whole point of QueryExecModeExec is to operate without having to know the PostgreSQL types there is
// no way to safely use binary or to specify the parameter OIDs. // no way to safely use binary or to specify the parameter OIDs.
func (c *Conn) appendParamsForQueryExecModeExec(args []interface{}) error { func (c *Conn) appendParamsForQueryExecModeExec(args []any) error {
for _, arg := range args { for _, arg := range args {
if arg == nil { if arg == nil {
err := c.eqb.AppendParamFormat(c.typeMap, 0, TextFormatCode, arg) err := c.eqb.AppendParamFormat(c.typeMap, 0, TextFormatCode, arg)
@@ -602,7 +602,7 @@ func (c *Conn) appendParamsForQueryExecModeExec(args []interface{}) error {
return nil return nil
} }
func (c *Conn) getRows(ctx context.Context, sql string, args []interface{}) *connRows { func (c *Conn) getRows(ctx context.Context, sql string, args []any) *connRows {
r := &connRows{} r := &connRows{}
r.ctx = ctx r.ctx = ctx
@@ -691,7 +691,7 @@ type QueryResultFormatsByOID map[uint32]int16
// For extra control over how the query is executed, the types QueryExecMode, QueryResultFormats, and // For extra control over how the query is executed, the types QueryExecMode, QueryResultFormats, and
// QueryResultFormatsByOID may be used as the first args to control exactly how the query is executed. This is rarely // QueryResultFormatsByOID may be used as the first args to control exactly how the query is executed. This is rarely
// needed. See the documentation for those types for details. // needed. See the documentation for those types for details.
func (c *Conn) Query(ctx context.Context, sql string, args ...interface{}) (Rows, error) { func (c *Conn) Query(ctx context.Context, sql string, args ...any) (Rows, error) {
var resultFormats QueryResultFormats var resultFormats QueryResultFormats
var resultFormatsByOID QueryResultFormatsByOID var resultFormatsByOID QueryResultFormatsByOID
mode := c.config.DefaultQueryExecMode mode := c.config.DefaultQueryExecMode
@@ -829,7 +829,7 @@ optionLoop:
// QueryRow is a convenience wrapper over Query. Any error that occurs while // QueryRow is a convenience wrapper over Query. Any error that occurs while
// querying is deferred until calling Scan on the returned Row. That Row will // querying is deferred until calling Scan on the returned Row. That Row will
// error with ErrNoRows if no rows are returned. // error with ErrNoRows if no rows are returned.
func (c *Conn) QueryRow(ctx context.Context, sql string, args ...interface{}) Row { func (c *Conn) QueryRow(ctx context.Context, sql string, args ...any) Row {
rows, _ := c.Query(ctx, sql, args...) rows, _ := c.Query(ctx, sql, args...)
return (*connRow)(rows.(*connRows)) return (*connRow)(rows.(*connRows))
} }
@@ -850,7 +850,7 @@ type QueryFuncRow interface {
// QueryFunc executes sql with args. For each row returned by the query the values will scanned into the elements of // QueryFunc executes sql with args. For each row returned by the query the values will scanned into the elements of
// scans and f will be called. If any row fails to scan or f returns an error the query will be aborted and the error // scans and f will be called. If any row fails to scan or f returns an error the query will be aborted and the error
// will be returned. // will be returned.
func (c *Conn) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(QueryFuncRow) error) (pgconn.CommandTag, error) { func (c *Conn) QueryFunc(ctx context.Context, sql string, args []any, scans []any, f func(QueryFuncRow) error) (pgconn.CommandTag, error) {
rows, err := c.Query(ctx, sql, args...) rows, err := c.Query(ctx, sql, args...)
if err != nil { if err != nil {
return pgconn.CommandTag{}, err return pgconn.CommandTag{}, err
@@ -1018,7 +1018,7 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) BatchResults {
} }
} }
func (c *Conn) sanitizeForSimpleQuery(sql string, args ...interface{}) (string, error) { func (c *Conn) sanitizeForSimpleQuery(sql string, args ...any) (string, error) {
if c.pgConn.ParameterStatus("standard_conforming_strings") != "on" { if c.pgConn.ParameterStatus("standard_conforming_strings") != "on" {
return "", errors.New("simple protocol queries must be run with standard_conforming_strings=on") return "", errors.New("simple protocol queries must be run with standard_conforming_strings=on")
} }
@@ -1028,7 +1028,7 @@ func (c *Conn) sanitizeForSimpleQuery(sql string, args ...interface{}) (string,
} }
var err error var err error
valueArgs := make([]interface{}, len(args)) valueArgs := make([]any, len(args))
for i, a := range args { for i, a := range args {
valueArgs[i], err = convertSimpleArgument(c.typeMap, a) valueArgs[i], err = convertSimpleArgument(c.typeMap, a)
if err != nil { if err != nil {
@@ -1108,8 +1108,8 @@ func (c *Conn) getCompositeFields(ctx context.Context, oid uint32) ([]pgtype.Com
from pg_attribute from pg_attribute
where attrelid=$1 where attrelid=$1
order by attnum`, order by attnum`,
[]interface{}{typrelid}, []any{typrelid},
[]interface{}{&fieldName, &fieldOID}, []any{&fieldName, &fieldOID},
func(qfr QueryFuncRow) error { func(qfr QueryFuncRow) error {
dt, ok := c.TypeMap().TypeForOID(fieldOID) dt, ok := c.TypeMap().TypeForOID(fieldOID)
if !ok { if !ok {
+2 -2
View File
@@ -711,14 +711,14 @@ func TestInsertTimestampArray(t *testing.T) {
type testLog struct { type testLog struct {
lvl pgx.LogLevel lvl pgx.LogLevel
msg string msg string
data map[string]interface{} data map[string]any
} }
type testLogger struct { type testLogger struct {
logs []testLog logs []testLog
} }
func (l *testLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{}) { func (l *testLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]any) {
data["ctxdata"] = ctx.Value("ctxdata") data["ctxdata"] = ctx.Value("ctxdata")
l.logs = append(l.logs, testLog{lvl: level, msg: msg, data: data}) l.logs = append(l.logs, testLog{lvl: level, msg: msg, data: data})
} }
+9 -9
View File
@@ -13,12 +13,12 @@ import (
// CopyFromRows returns a CopyFromSource interface over the provided rows slice // CopyFromRows returns a CopyFromSource interface over the provided rows slice
// making it usable by *Conn.CopyFrom. // making it usable by *Conn.CopyFrom.
func CopyFromRows(rows [][]interface{}) CopyFromSource { func CopyFromRows(rows [][]any) CopyFromSource {
return &copyFromRows{rows: rows, idx: -1} return &copyFromRows{rows: rows, idx: -1}
} }
type copyFromRows struct { type copyFromRows struct {
rows [][]interface{} rows [][]any
idx int idx int
} }
@@ -27,7 +27,7 @@ func (ctr *copyFromRows) Next() bool {
return ctr.idx < len(ctr.rows) return ctr.idx < len(ctr.rows)
} }
func (ctr *copyFromRows) Values() ([]interface{}, error) { func (ctr *copyFromRows) Values() ([]any, error) {
return ctr.rows[ctr.idx], nil return ctr.rows[ctr.idx], nil
} }
@@ -37,12 +37,12 @@ func (ctr *copyFromRows) Err() error {
// CopyFromSlice returns a CopyFromSource interface over a dynamic func // CopyFromSlice returns a CopyFromSource interface over a dynamic func
// making it usable by *Conn.CopyFrom. // making it usable by *Conn.CopyFrom.
func CopyFromSlice(length int, next func(int) ([]interface{}, error)) CopyFromSource { func CopyFromSlice(length int, next func(int) ([]any, error)) CopyFromSource {
return &copyFromSlice{next: next, idx: -1, len: length} return &copyFromSlice{next: next, idx: -1, len: length}
} }
type copyFromSlice struct { type copyFromSlice struct {
next func(int) ([]interface{}, error) next func(int) ([]any, error)
idx int idx int
len int len int
err error err error
@@ -53,7 +53,7 @@ func (cts *copyFromSlice) Next() bool {
return cts.idx < cts.len return cts.idx < cts.len
} }
func (cts *copyFromSlice) Values() ([]interface{}, error) { func (cts *copyFromSlice) Values() ([]any, error) {
values, err := cts.next(cts.idx) values, err := cts.next(cts.idx)
if err != nil { if err != nil {
cts.err = err cts.err = err
@@ -73,7 +73,7 @@ type CopyFromSource interface {
Next() bool Next() bool
// Values returns the values for the current row. // Values returns the values for the current row.
Values() ([]interface{}, error) Values() ([]any, error)
// Err returns any error that has been encountered by the CopyFromSource. If // Err returns any error that has been encountered by the CopyFromSource. If
// this is not nil *Conn.CopyFrom will abort the copy. // this is not nil *Conn.CopyFrom will abort the copy.
@@ -156,10 +156,10 @@ func (ct *copyFrom) run(ctx context.Context) (int64, error) {
if err == nil { if err == nil {
if ct.conn.shouldLog(LogLevelInfo) { if ct.conn.shouldLog(LogLevelInfo) {
endTime := time.Now() endTime := time.Now()
ct.conn.log(ctx, LogLevelInfo, "CopyFrom", map[string]interface{}{"tableName": ct.tableName, "columnNames": ct.columnNames, "time": endTime.Sub(startTime), "rowCount": rowsAffected}) ct.conn.log(ctx, LogLevelInfo, "CopyFrom", map[string]any{"tableName": ct.tableName, "columnNames": ct.columnNames, "time": endTime.Sub(startTime), "rowCount": rowsAffected})
} }
} else if ct.conn.shouldLog(LogLevelError) { } else if ct.conn.shouldLog(LogLevelError) {
ct.conn.log(ctx, LogLevelError, "CopyFrom", map[string]interface{}{"err": err, "tableName": ct.tableName, "columnNames": ct.columnNames}) ct.conn.log(ctx, LogLevelError, "CopyFrom", map[string]any{"err": err, "tableName": ct.tableName, "columnNames": ct.columnNames})
} }
return rowsAffected, err return rowsAffected, err
+28 -28
View File
@@ -32,7 +32,7 @@ func TestConnCopyFromSmall(t *testing.T) {
tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local) tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local)
inputRows := [][]interface{}{ inputRows := [][]any{
{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime}, {int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime},
{nil, nil, nil, nil, nil, nil, nil}, {nil, nil, nil, nil, nil, nil, nil},
} }
@@ -50,7 +50,7 @@ func TestConnCopyFromSmall(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -88,13 +88,13 @@ func TestConnCopyFromSliceSmall(t *testing.T) {
tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local) tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local)
inputRows := [][]interface{}{ inputRows := [][]any{
{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime}, {int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime},
{nil, nil, nil, nil, nil, nil, nil}, {nil, nil, nil, nil, nil, nil, nil},
} }
copyCount, err := conn.CopyFrom(context.Background(), pgx.Identifier{"foo"}, []string{"a", "b", "c", "d", "e", "f", "g"}, copyCount, err := conn.CopyFrom(context.Background(), pgx.Identifier{"foo"}, []string{"a", "b", "c", "d", "e", "f", "g"},
pgx.CopyFromSlice(len(inputRows), func(i int) ([]interface{}, error) { pgx.CopyFromSlice(len(inputRows), func(i int) ([]any, error) {
return inputRows[i], nil return inputRows[i], nil
})) }))
if err != nil { if err != nil {
@@ -109,7 +109,7 @@ func TestConnCopyFromSliceSmall(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -150,10 +150,10 @@ func TestConnCopyFromLarge(t *testing.T) {
tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local) tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local)
inputRows := [][]interface{}{} inputRows := [][]any{}
for i := 0; i < 10000; i++ { for i := 0; i < 10000; i++ {
inputRows = append(inputRows, []interface{}{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime, []byte{111, 111, 111, 111}}) inputRows = append(inputRows, []any{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime, []byte{111, 111, 111, 111}})
} }
copyCount, err := conn.CopyFrom(context.Background(), pgx.Identifier{"foo"}, []string{"a", "b", "c", "d", "e", "f", "g", "h"}, pgx.CopyFromRows(inputRows)) copyCount, err := conn.CopyFrom(context.Background(), pgx.Identifier{"foo"}, []string{"a", "b", "c", "d", "e", "f", "g", "h"}, pgx.CopyFromRows(inputRows))
@@ -169,7 +169,7 @@ func TestConnCopyFromLarge(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -230,7 +230,7 @@ func TestConnCopyFromEnum(t *testing.T) {
)`) )`)
require.NoError(t, err) require.NoError(t, err)
inputRows := [][]interface{}{ inputRows := [][]any{
{"abc", "blue", "grape", "orange", "orange", "def"}, {"abc", "blue", "grape", "orange", "orange", "def"},
{nil, nil, nil, nil, nil, nil}, {nil, nil, nil, nil, nil, nil},
} }
@@ -242,7 +242,7 @@ func TestConnCopyFromEnum(t *testing.T) {
rows, err := conn.Query(ctx, "select * from foo") rows, err := conn.Query(ctx, "select * from foo")
require.NoError(t, err) require.NoError(t, err)
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
require.NoError(t, err) require.NoError(t, err)
@@ -275,8 +275,8 @@ func TestConnCopyFromJSON(t *testing.T) {
b jsonb b jsonb
)`) )`)
inputRows := [][]interface{}{ inputRows := [][]any{
{map[string]interface{}{"foo": "bar"}, map[string]interface{}{"bar": "quz"}}, {map[string]any{"foo": "bar"}, map[string]any{"bar": "quz"}},
{nil, nil}, {nil, nil},
} }
@@ -293,7 +293,7 @@ func TestConnCopyFromJSON(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -323,12 +323,12 @@ func (cfs *clientFailSource) Next() bool {
return cfs.count < 100 return cfs.count < 100
} }
func (cfs *clientFailSource) Values() ([]interface{}, error) { func (cfs *clientFailSource) Values() ([]any, error) {
if cfs.count == 3 { if cfs.count == 3 {
cfs.err = fmt.Errorf("client error") cfs.err = fmt.Errorf("client error")
return nil, cfs.err return nil, cfs.err
} }
return []interface{}{make([]byte, 100000)}, nil return []any{make([]byte, 100000)}, nil
} }
func (cfs *clientFailSource) Err() error { func (cfs *clientFailSource) Err() error {
@@ -346,7 +346,7 @@ func TestConnCopyFromFailServerSideMidway(t *testing.T) {
b varchar not null b varchar not null
)`) )`)
inputRows := [][]interface{}{ inputRows := [][]any{
{int32(1), "abc"}, {int32(1), "abc"},
{int32(2), nil}, // this row should trigger a failure {int32(2), nil}, // this row should trigger a failure
{int32(3), "def"}, {int32(3), "def"},
@@ -368,7 +368,7 @@ func TestConnCopyFromFailServerSideMidway(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -400,11 +400,11 @@ func (fs *failSource) Next() bool {
return fs.count < 100 return fs.count < 100
} }
func (fs *failSource) Values() ([]interface{}, error) { func (fs *failSource) Values() ([]any, error) {
if fs.count == 3 { if fs.count == 3 {
return []interface{}{nil}, nil return []any{nil}, nil
} }
return []interface{}{make([]byte, 100000)}, nil return []any{make([]byte, 100000)}, nil
} }
func (fs *failSource) Err() error { func (fs *failSource) Err() error {
@@ -447,7 +447,7 @@ func TestConnCopyFromFailServerSideMidwayAbortsWithoutWaiting(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -477,11 +477,11 @@ func (fs *slowFailRaceSource) Next() bool {
return fs.count < 1000 return fs.count < 1000
} }
func (fs *slowFailRaceSource) Values() ([]interface{}, error) { func (fs *slowFailRaceSource) Values() ([]any, error) {
if fs.count == 500 { if fs.count == 500 {
return []interface{}{nil, nil}, nil return []any{nil, nil}, nil
} }
return []interface{}{1, make([]byte, 1000)}, nil return []any{1, make([]byte, 1000)}, nil
} }
func (fs *slowFailRaceSource) Err() error { func (fs *slowFailRaceSource) Err() error {
@@ -536,7 +536,7 @@ func TestConnCopyFromCopyFromSourceErrorMidway(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
@@ -565,8 +565,8 @@ func (cfs *clientFinalErrSource) Next() bool {
return cfs.count < 5 return cfs.count < 5
} }
func (cfs *clientFinalErrSource) Values() ([]interface{}, error) { func (cfs *clientFinalErrSource) Values() ([]any, error) {
return []interface{}{make([]byte, 100000)}, nil return []any{make([]byte, 100000)}, nil
} }
func (cfs *clientFinalErrSource) Err() error { func (cfs *clientFinalErrSource) Err() error {
@@ -596,7 +596,7 @@ func TestConnCopyFromCopyFromSourceErrorEnd(t *testing.T) {
t.Errorf("Unexpected error for Query: %v", err) t.Errorf("Unexpected error for Query: %v", err)
} }
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
+6 -6
View File
@@ -88,8 +88,8 @@ QueryFunc can be used to execute a callback function for every row. This is ofte
_, err = conn.QueryFunc( _, err = conn.QueryFunc(
context.Background(), context.Background(),
"select generate_series(1,$1)", "select generate_series(1,$1)",
[]interface{}{10}, []any{10},
[]interface{}{&n}, []any{&n},
func(pgx.QueryFuncRow) error { func(pgx.QueryFuncRow) error {
sum += n sum += n
return nil return nil
@@ -273,10 +273,10 @@ for information on how to customize or disable the statement cache.
Copy Protocol Copy Protocol
Use CopyFrom to efficiently insert multiple rows at a time using the PostgreSQL copy protocol. CopyFrom accepts a Use CopyFrom to efficiently insert multiple rows at a time using the PostgreSQL copy protocol. CopyFrom accepts a
CopyFromSource interface. If the data is already in a [][]interface{} use CopyFromRows to wrap it in a CopyFromSource CopyFromSource interface. If the data is already in a [][]any use CopyFromRows to wrap it in a CopyFromSource
interface. Or implement CopyFromSource to avoid buffering the entire data set in memory. interface. Or implement CopyFromSource to avoid buffering the entire data set in memory.
rows := [][]interface{}{ rows := [][]any{
{"John", "Smith", int32(36)}, {"John", "Smith", int32(36)},
{"Jane", "Doe", int32(29)}, {"Jane", "Doe", int32(29)},
} }
@@ -299,8 +299,8 @@ When you already have a typed array using CopyFromSlice can be more convenient.
context.Background(), context.Background(),
pgx.Identifier{"people"}, pgx.Identifier{"people"},
[]string{"first_name", "last_name", "age"}, []string{"first_name", "last_name", "age"},
pgx.CopyFromSlice(len(rows), func(i int) ([]interface{}, error) { pgx.CopyFromSlice(len(rows), func(i int) ([]any, error) {
return []interface{}{rows[i].FirstName, rows[i].LastName, rows[i].Age}, nil return []any{rows[i].FirstName, rows[i].LastName, rows[i].Age}, nil
}), }),
) )
+4 -4
View File
@@ -12,12 +12,12 @@ type extendedQueryBuilder struct {
resultFormats []int16 resultFormats []int16
} }
func (eqb *extendedQueryBuilder) AppendParam(m *pgtype.Map, oid uint32, arg interface{}) error { func (eqb *extendedQueryBuilder) AppendParam(m *pgtype.Map, oid uint32, arg any) error {
f := eqb.chooseParameterFormatCode(m, oid, arg) f := eqb.chooseParameterFormatCode(m, oid, arg)
return eqb.AppendParamFormat(m, oid, f, arg) return eqb.AppendParamFormat(m, oid, f, arg)
} }
func (eqb *extendedQueryBuilder) AppendParamFormat(m *pgtype.Map, oid uint32, format int16, arg interface{}) error { func (eqb *extendedQueryBuilder) AppendParamFormat(m *pgtype.Map, oid uint32, format int16, arg any) error {
eqb.paramFormats = append(eqb.paramFormats, format) eqb.paramFormats = append(eqb.paramFormats, format)
v, err := eqb.encodeExtendedParamValue(m, oid, format, arg) v, err := eqb.encodeExtendedParamValue(m, oid, format, arg)
@@ -56,7 +56,7 @@ func (eqb *extendedQueryBuilder) Reset() {
} }
} }
func (eqb *extendedQueryBuilder) encodeExtendedParamValue(m *pgtype.Map, oid uint32, formatCode int16, arg interface{}) ([]byte, error) { func (eqb *extendedQueryBuilder) encodeExtendedParamValue(m *pgtype.Map, oid uint32, formatCode int16, arg any) ([]byte, error) {
if anynil.Is(arg) { if anynil.Is(arg) {
return nil, nil return nil, nil
} }
@@ -81,7 +81,7 @@ func (eqb *extendedQueryBuilder) encodeExtendedParamValue(m *pgtype.Map, oid uin
// chooseParameterFormatCode determines the correct format code for an // chooseParameterFormatCode determines the correct format code for an
// argument to a prepared statement. It defaults to TextFormatCode if no // argument to a prepared statement. It defaults to TextFormatCode if no
// determination can be made. // determination can be made.
func (eqb *extendedQueryBuilder) chooseParameterFormatCode(m *pgtype.Map, oid uint32, arg interface{}) int16 { func (eqb *extendedQueryBuilder) chooseParameterFormatCode(m *pgtype.Map, oid uint32, arg any) int16 {
switch arg.(type) { switch arg.(type) {
case string, *string: case string, *string:
return TextFormatCode return TextFormatCode
+1 -1
View File
@@ -53,7 +53,7 @@ func closeConn(t testing.TB, conn *pgx.Conn) {
} }
} }
func mustExec(t testing.TB, conn *pgx.Conn, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag) { func mustExec(t testing.TB, conn *pgx.Conn, sql string, arguments ...any) (commandTag pgconn.CommandTag) {
var err error var err error
if commandTag, err = conn.Exec(context.Background(), sql, arguments...); err != nil { if commandTag, err = conn.Exec(context.Background(), sql, arguments...); err != nil {
t.Fatalf("Exec unexpectedly failed with %v: %v", sql, err) t.Fatalf("Exec unexpectedly failed with %v: %v", sql, err)
+3 -3
View File
@@ -3,7 +3,7 @@ package anynil
import "reflect" import "reflect"
// Is returns true if value is any type of nil. e.g. nil or []byte(nil). // Is returns true if value is any type of nil. e.g. nil or []byte(nil).
func Is(value interface{}) bool { func Is(value any) bool {
if value == nil { if value == nil {
return true return true
} }
@@ -18,7 +18,7 @@ func Is(value interface{}) bool {
} }
// Normalize converts typed nils (e.g. []byte(nil)) into untyped nil. Other values are returned unmodified. // Normalize converts typed nils (e.g. []byte(nil)) into untyped nil. Other values are returned unmodified.
func Normalize(v interface{}) interface{} { func Normalize(v any) any {
if Is(v) { if Is(v) {
return nil return nil
} }
@@ -27,7 +27,7 @@ func Normalize(v interface{}) interface{} {
// NormalizeSlice converts all typed nils (e.g. []byte(nil)) in s into untyped nils. Other values are unmodified. s is // NormalizeSlice converts all typed nils (e.g. []byte(nil)) in s into untyped nils. Other values are unmodified. s is
// mutated in place. // mutated in place.
func NormalizeSlice(s []interface{}) { func NormalizeSlice(s []any) {
for i := range s { for i := range s {
if Is(s[i]) { if Is(s[i]) {
s[i] = nil s[i] = nil
+3 -3
View File
@@ -12,13 +12,13 @@ import (
// Part is either a string or an int. A string is raw SQL. An int is a // Part is either a string or an int. A string is raw SQL. An int is a
// argument placeholder. // argument placeholder.
type Part interface{} type Part any
type Query struct { type Query struct {
Parts []Part Parts []Part
} }
func (q *Query) Sanitize(args ...interface{}) (string, error) { func (q *Query) Sanitize(args ...any) (string, error) {
argUse := make([]bool, len(args)) argUse := make([]bool, len(args))
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
@@ -295,7 +295,7 @@ func multilineCommentState(l *sqlLexer) stateFn {
// SanitizeSQL replaces placeholder values with args. It quotes and escapes args // SanitizeSQL replaces placeholder values with args. It quotes and escapes args
// as necessary. This function is only safe when standard_conforming_strings is // as necessary. This function is only safe when standard_conforming_strings is
// on. // on.
func SanitizeSQL(sql string, args ...interface{}) (string, error) { func SanitizeSQL(sql string, args ...any) (string, error) {
query, err := NewQuery(sql) query, err := NewQuery(sql)
if err != nil { if err != nil {
return "", err return "", err
+15 -15
View File
@@ -107,57 +107,57 @@ func TestNewQuery(t *testing.T) {
func TestQuerySanitize(t *testing.T) { func TestQuerySanitize(t *testing.T) {
successfulTests := []struct { successfulTests := []struct {
query sanitize.Query query sanitize.Query
args []interface{} args []any
expected string expected string
}{ }{
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select 42"}}, query: sanitize.Query{Parts: []sanitize.Part{"select 42"}},
args: []interface{}{}, args: []any{},
expected: `select 42`, expected: `select 42`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{int64(42)}, args: []any{int64(42)},
expected: `select 42`, expected: `select 42`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{float64(1.23)}, args: []any{float64(1.23)},
expected: `select 1.23`, expected: `select 1.23`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{true}, args: []any{true},
expected: `select true`, expected: `select true`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{[]byte{0, 1, 2, 3, 255}}, args: []any{[]byte{0, 1, 2, 3, 255}},
expected: `select '\x00010203ff'`, expected: `select '\x00010203ff'`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{nil}, args: []any{nil},
expected: `select null`, expected: `select null`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{"foobar"}, args: []any{"foobar"},
expected: `select 'foobar'`, expected: `select 'foobar'`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{"foo'bar"}, args: []any{"foo'bar"},
expected: `select 'foo''bar'`, expected: `select 'foo''bar'`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{`foo\'bar`}, args: []any{`foo\'bar`},
expected: `select 'foo\''bar'`, expected: `select 'foo\''bar'`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"insert ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"insert ", 1}},
args: []interface{}{time.Date(2020, time.March, 1, 23, 59, 59, 999999999, time.UTC)}, args: []any{time.Date(2020, time.March, 1, 23, 59, 59, 999999999, time.UTC)},
expected: `insert '2020-03-01 23:59:59.999999Z'`, expected: `insert '2020-03-01 23:59:59.999999Z'`,
}, },
} }
@@ -176,22 +176,22 @@ func TestQuerySanitize(t *testing.T) {
errorTests := []struct { errorTests := []struct {
query sanitize.Query query sanitize.Query
args []interface{} args []any
expected string expected string
}{ }{
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1, ", ", 2}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1, ", ", 2}},
args: []interface{}{int64(42)}, args: []any{int64(42)},
expected: `insufficient arguments`, expected: `insufficient arguments`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select 'foo'"}}, query: sanitize.Query{Parts: []sanitize.Part{"select 'foo'"}},
args: []interface{}{int64(42)}, args: []any{int64(42)},
expected: `unused argument: 0`, expected: `unused argument: 0`,
}, },
{ {
query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}}, query: sanitize.Query{Parts: []sanitize.Part{"select ", 1}},
args: []interface{}{42}, args: []any{42},
expected: `invalid arg type: int`, expected: `invalid arg type: int`,
}, },
} }
+3 -3
View File
@@ -12,7 +12,7 @@ import (
// TestingLogger interface defines the subset of testing.TB methods used by this // TestingLogger interface defines the subset of testing.TB methods used by this
// adapter. // adapter.
type TestingLogger interface { type TestingLogger interface {
Log(args ...interface{}) Log(args ...any)
} }
type Logger struct { type Logger struct {
@@ -23,8 +23,8 @@ func NewLogger(l TestingLogger) *Logger {
return &Logger{l: l} return &Logger{l: l}
} }
func (l *Logger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{}) { func (l *Logger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]any) {
logArgs := make([]interface{}, 0, 2+len(data)) logArgs := make([]any, 0, 2+len(data))
logArgs = append(logArgs, level, msg) logArgs = append(logArgs, level, msg)
for k, v := range data { for k, v := range data {
logArgs = append(logArgs, fmt.Sprintf("%s=%v", k, v)) logArgs = append(logArgs, fmt.Sprintf("%s=%v", k, v))
+3 -3
View File
@@ -44,7 +44,7 @@ func (ll LogLevel) String() string {
// Logger is the interface used to get logging from pgx internals. // Logger is the interface used to get logging from pgx internals.
type Logger interface { type Logger interface {
// Log a message at the given level with data key/value pairs. data may be nil. // Log a message at the given level with data key/value pairs. data may be nil.
Log(ctx context.Context, level LogLevel, msg string, data map[string]interface{}) Log(ctx context.Context, level LogLevel, msg string, data map[string]any)
} }
// LogLevelFromString converts log level string to constant // LogLevelFromString converts log level string to constant
@@ -75,8 +75,8 @@ func LogLevelFromString(s string) (LogLevel, error) {
} }
} }
func logQueryArgs(args []interface{}) []interface{} { func logQueryArgs(args []any) []any {
logArgs := make([]interface{}, 0, len(args)) logArgs := make([]any, 0, len(args))
for _, a := range args { for _, a := range args {
switch v := a.(type) { switch v := a.(type) {
+1 -1
View File
@@ -20,7 +20,7 @@ func init() {
for i := range bigBufPools { for i := range bigBufPools {
byteSize := bigBufSizes[i] byteSize := bigBufSizes[i]
bigBufPools[i] = &bigBufPool{ bigBufPools[i] = &bigBufPool{
pool: sync.Pool{New: func() interface{} { return make([]byte, byteSize) }}, pool: sync.Pool{New: func() any { return make([]byte, byteSize) }},
byteSize: byteSize, byteSize: byteSize,
} }
} }
+11 -11
View File
@@ -15,10 +15,10 @@ type ArrayGetter interface {
Dimensions() []ArrayDimension Dimensions() []ArrayDimension
// Index returns the element at i. // Index returns the element at i.
Index(i int) interface{} Index(i int) any
// IndexType returns a non-nil scan target of the type Index will return. This is used by ArrayCodec.PlanEncode. // IndexType returns a non-nil scan target of the type Index will return. This is used by ArrayCodec.PlanEncode.
IndexType() interface{} IndexType() any
} }
// ArraySetter is a type can be set from a PostgreSQL array. // ArraySetter is a type can be set from a PostgreSQL array.
@@ -29,11 +29,11 @@ type ArraySetter interface {
SetDimensions(dimensions []ArrayDimension) error SetDimensions(dimensions []ArrayDimension) error
// ScanIndex returns a value usable as a scan target for i. SetDimensions must be called before ScanIndex. // ScanIndex returns a value usable as a scan target for i. SetDimensions must be called before ScanIndex.
ScanIndex(i int) interface{} ScanIndex(i int) any
// ScanIndexType returns a non-nil scan target of the type ScanIndex will return. This is used by // ScanIndexType returns a non-nil scan target of the type ScanIndex will return. This is used by
// ArrayCodec.PlanScan. // ArrayCodec.PlanScan.
ScanIndexType() interface{} ScanIndexType() any
} }
// ArrayCodec is a codec for any array type. // ArrayCodec is a codec for any array type.
@@ -49,7 +49,7 @@ func (c *ArrayCodec) PreferredFormat() int16 {
return c.ElementType.Codec.PreferredFormat() return c.ElementType.Codec.PreferredFormat()
} }
func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
arrayValuer, ok := value.(ArrayGetter) arrayValuer, ok := value.(ArrayGetter)
if !ok { if !ok {
return nil return nil
@@ -78,7 +78,7 @@ type encodePlanArrayCodecText struct {
oid uint32 oid uint32
} }
func (p *encodePlanArrayCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (p *encodePlanArrayCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
array := value.(ArrayGetter) array := value.(ArrayGetter)
dimensions := array.Dimensions() dimensions := array.Dimensions()
@@ -157,7 +157,7 @@ type encodePlanArrayCodecBinary struct {
oid uint32 oid uint32
} }
func (p *encodePlanArrayCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (p *encodePlanArrayCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
array := value.(ArrayGetter) array := value.(ArrayGetter)
dimensions := array.Dimensions() dimensions := array.Dimensions()
@@ -210,7 +210,7 @@ func (p *encodePlanArrayCodecBinary) Encode(value interface{}, buf []byte) (newB
return buf, nil return buf, nil
} }
func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
arrayScanner, ok := target.(ArraySetter) arrayScanner, ok := target.(ArraySetter)
if !ok { if !ok {
return nil return nil
@@ -315,7 +315,7 @@ type scanPlanArrayCodec struct {
elementScanPlan ScanPlan elementScanPlan ScanPlan
} }
func (spac *scanPlanArrayCodec) Scan(src []byte, dst interface{}) error { func (spac *scanPlanArrayCodec) Scan(src []byte, dst any) error {
c := spac.arrayCodec c := spac.arrayCodec
m := spac.m m := spac.m
oid := spac.oid oid := spac.oid
@@ -354,12 +354,12 @@ func (c *ArrayCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
} }
} }
func (c *ArrayCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c *ArrayCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
var slice []interface{} var slice []any
err := m.PlanScan(oid, format, &slice).Scan(src, &slice) err := m.PlanScan(oid, format, &slice).Scan(src, &slice)
return slice, err return slice, err
} }
+7 -7
View File
@@ -12,7 +12,7 @@ import (
func TestArrayCodec(t *testing.T) { func TestArrayCodec(t *testing.T) {
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
for i, tt := range []struct { for i, tt := range []struct {
expected interface{} expected any
}{ }{
{[]int16(nil)}, {[]int16(nil)},
{[]int16{}}, {[]int16{}},
@@ -31,7 +31,7 @@ func TestArrayCodec(t *testing.T) {
newInt16 := func(n int16) *int16 { return &n } newInt16 := func(n int16) *int16 { return &n }
for i, tt := range []struct { for i, tt := range []struct {
expected interface{} expected any
}{ }{
{[]*int16{newInt16(1), nil, newInt16(3), nil, newInt16(5)}}, {[]*int16{newInt16(1), nil, newInt16(3), nil, newInt16(5)}},
} { } {
@@ -52,7 +52,7 @@ func TestArrayCodecAnySlice(t *testing.T) {
type _int16Slice []int16 type _int16Slice []int16
for i, tt := range []struct { for i, tt := range []struct {
expected interface{} expected any
}{ }{
{_int16Slice(nil)}, {_int16Slice(nil)},
{_int16Slice{}}, {_int16Slice{}},
@@ -74,19 +74,19 @@ func TestArrayCodecDecodeValue(t *testing.T) {
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) { defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) {
for _, tt := range []struct { for _, tt := range []struct {
sql string sql string
expected interface{} expected any
}{ }{
{ {
sql: `select '{}'::int4[]`, sql: `select '{}'::int4[]`,
expected: []interface{}{}, expected: []any{},
}, },
{ {
sql: `select '{1,2}'::int8[]`, sql: `select '{1,2}'::int8[]`,
expected: []interface{}{int64(1), int64(2)}, expected: []any{int64(1), int64(2)},
}, },
{ {
sql: `select '{foo,bar}'::text[]`, sql: `select '{foo,bar}'::text[]`,
expected: []interface{}{"foo", "bar"}, expected: []any{"foo", "bar"},
}, },
} { } {
t.Run(tt.sql, func(t *testing.T) { t.Run(tt.sql, func(t *testing.T) {
+8 -8
View File
@@ -11,11 +11,11 @@ func (a int16Array) Dimensions() []ArrayDimension {
return []ArrayDimension{{Length: int32(len(a)), LowerBound: 1}} return []ArrayDimension{{Length: int32(len(a)), LowerBound: 1}}
} }
func (a int16Array) Index(i int) interface{} { func (a int16Array) Index(i int) any {
return a[i] return a[i]
} }
func (a int16Array) IndexType() interface{} { func (a int16Array) IndexType() any {
var el int16 var el int16
return el return el
} }
@@ -31,11 +31,11 @@ func (a *int16Array) SetDimensions(dimensions []ArrayDimension) error {
return nil return nil
} }
func (a int16Array) ScanIndex(i int) interface{} { func (a int16Array) ScanIndex(i int) any {
return &a[i] return &a[i]
} }
func (a int16Array) ScanIndexType() interface{} { func (a int16Array) ScanIndexType() any {
return new(int16) return new(int16)
} }
@@ -49,11 +49,11 @@ func (a uint16Array) Dimensions() []ArrayDimension {
return []ArrayDimension{{Length: int32(len(a)), LowerBound: 1}} return []ArrayDimension{{Length: int32(len(a)), LowerBound: 1}}
} }
func (a uint16Array) Index(i int) interface{} { func (a uint16Array) Index(i int) any {
return a[i] return a[i]
} }
func (a uint16Array) IndexType() interface{} { func (a uint16Array) IndexType() any {
var el uint16 var el uint16
return el return el
} }
@@ -69,10 +69,10 @@ func (a *uint16Array) SetDimensions(dimensions []ArrayDimension) error {
return nil return nil
} }
func (a uint16Array) ScanIndex(i int) interface{} { func (a uint16Array) ScanIndex(i int) any {
return &a[i] return &a[i]
} }
func (a uint16Array) ScanIndexType() interface{} { func (a uint16Array) ScanIndexType() any {
return new(uint16) return new(uint16)
} }
+4 -4
View File
@@ -23,11 +23,11 @@ import (
return []ArrayDimension{{Length: int32(len(a)), LowerBound: 1}} return []ArrayDimension{{Length: int32(len(a)), LowerBound: 1}}
} }
func (a <%= array_type %>) Index(i int) interface{} { func (a <%= array_type %>) Index(i int) any {
return a[i] return a[i]
} }
func (a <%= array_type %>) IndexType() interface{} { func (a <%= array_type %>) IndexType() any {
var el <%= element_type %> var el <%= element_type %>
return el return el
} }
@@ -43,11 +43,11 @@ import (
return nil return nil
} }
func (a <%= array_type %>) ScanIndex(i int) interface{} { func (a <%= array_type %>) ScanIndex(i int) any {
return &a[i] return &a[i]
} }
func (a <%= array_type %>) ScanIndexType() interface{} { func (a <%= array_type %>) ScanIndexType() any {
return new(<%= element_type %>) return new(<%= element_type %>)
} }
<% end %> <% end %>
+8 -8
View File
@@ -33,7 +33,7 @@ func (b Bits) BitsValue() (Bits, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Bits) Scan(src interface{}) error { func (dst *Bits) Scan(src any) error {
if src == nil { if src == nil {
*dst = Bits{} *dst = Bits{}
return nil return nil
@@ -70,7 +70,7 @@ func (BitsCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (BitsCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (BitsCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(BitsValuer); !ok { if _, ok := value.(BitsValuer); !ok {
return nil return nil
} }
@@ -87,7 +87,7 @@ func (BitsCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanBitsCodecBinary struct{} type encodePlanBitsCodecBinary struct{}
func (encodePlanBitsCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBitsCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
bits, err := value.(BitsValuer).BitsValue() bits, err := value.(BitsValuer).BitsValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -103,7 +103,7 @@ func (encodePlanBitsCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanBitsCodecText struct{} type encodePlanBitsCodecText struct{}
func (encodePlanBitsCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBitsCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
bits, err := value.(BitsValuer).BitsValue() bits, err := value.(BitsValuer).BitsValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -126,7 +126,7 @@ func (encodePlanBitsCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil return buf, nil
} }
func (BitsCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (BitsCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -148,7 +148,7 @@ func (c BitsCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c BitsCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c BitsCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -163,7 +163,7 @@ func (c BitsCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanBinaryBitsToBitsScanner struct{} type scanPlanBinaryBitsToBitsScanner struct{}
func (scanPlanBinaryBitsToBitsScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryBitsToBitsScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BitsScanner) scanner := (dst).(BitsScanner)
if src == nil { if src == nil {
@@ -182,7 +182,7 @@ func (scanPlanBinaryBitsToBitsScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToBitsScanner struct{} type scanPlanTextAnyToBitsScanner struct{}
func (scanPlanTextAnyToBitsScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToBitsScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BitsScanner) scanner := (dst).(BitsScanner)
if src == nil { if src == nil {
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqBits(a interface{}) func(interface{}) bool { func isExpectedEqBits(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
ab := a.(pgtype.Bits) ab := a.(pgtype.Bits)
vb := v.(pgtype.Bits) vb := v.(pgtype.Bits)
return bytes.Compare(ab.Bytes, vb.Bytes) == 0 && ab.Len == vb.Len && ab.Valid == vb.Valid return bytes.Compare(ab.Bytes, vb.Bytes) == 0 && ab.Len == vb.Len && ab.Valid == vb.Valid
+12 -12
View File
@@ -30,7 +30,7 @@ func (b Bool) BoolValue() (Bool, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Bool) Scan(src interface{}) error { func (dst *Bool) Scan(src any) error {
if src == nil { if src == nil {
*dst = Bool{} *dst = Bool{}
return nil return nil
@@ -106,7 +106,7 @@ func (BoolCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (BoolCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (BoolCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -129,7 +129,7 @@ func (BoolCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanBoolCodecBinaryBool struct{} type encodePlanBoolCodecBinaryBool struct{}
func (encodePlanBoolCodecBinaryBool) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBoolCodecBinaryBool) Encode(value any, buf []byte) (newBuf []byte, err error) {
v := value.(bool) v := value.(bool)
if v { if v {
@@ -143,7 +143,7 @@ func (encodePlanBoolCodecBinaryBool) Encode(value interface{}, buf []byte) (newB
type encodePlanBoolCodecTextBoolValuer struct{} type encodePlanBoolCodecTextBoolValuer struct{}
func (encodePlanBoolCodecTextBoolValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBoolCodecTextBoolValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
b, err := value.(BoolValuer).BoolValue() b, err := value.(BoolValuer).BoolValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -164,7 +164,7 @@ func (encodePlanBoolCodecTextBoolValuer) Encode(value interface{}, buf []byte) (
type encodePlanBoolCodecBinaryBoolValuer struct{} type encodePlanBoolCodecBinaryBoolValuer struct{}
func (encodePlanBoolCodecBinaryBoolValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBoolCodecBinaryBoolValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
b, err := value.(BoolValuer).BoolValue() b, err := value.(BoolValuer).BoolValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -185,7 +185,7 @@ func (encodePlanBoolCodecBinaryBoolValuer) Encode(value interface{}, buf []byte)
type encodePlanBoolCodecTextBool struct{} type encodePlanBoolCodecTextBool struct{}
func (encodePlanBoolCodecTextBool) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBoolCodecTextBool) Encode(value any, buf []byte) (newBuf []byte, err error) {
v := value.(bool) v := value.(bool)
if v { if v {
@@ -197,7 +197,7 @@ func (encodePlanBoolCodecTextBool) Encode(value interface{}, buf []byte) (newBuf
return buf, nil return buf, nil
} }
func (BoolCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (BoolCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -223,7 +223,7 @@ func (c BoolCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return c.DecodeValue(m, oid, format, src) return c.DecodeValue(m, oid, format, src)
} }
func (c BoolCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c BoolCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -238,7 +238,7 @@ func (c BoolCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanBinaryBoolToBool struct{} type scanPlanBinaryBoolToBool struct{}
func (scanPlanBinaryBoolToBool) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryBoolToBool) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -259,7 +259,7 @@ func (scanPlanBinaryBoolToBool) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToBool struct{} type scanPlanTextAnyToBool struct{}
func (scanPlanTextAnyToBool) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToBool) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -280,7 +280,7 @@ func (scanPlanTextAnyToBool) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryBoolToBoolScanner struct{} type scanPlanBinaryBoolToBoolScanner struct{}
func (scanPlanBinaryBoolToBoolScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryBoolToBoolScanner) Scan(src []byte, dst any) error {
s, ok := (dst).(BoolScanner) s, ok := (dst).(BoolScanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -299,7 +299,7 @@ func (scanPlanBinaryBoolToBoolScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToBoolScanner struct{} type scanPlanTextAnyToBoolScanner struct{}
func (scanPlanTextAnyToBoolScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToBoolScanner) Scan(src []byte, dst any) error {
s, ok := (dst).(BoolScanner) s, ok := (dst).(BoolScanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
+8 -8
View File
@@ -34,7 +34,7 @@ func (b Box) BoxValue() (Box, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Box) Scan(src interface{}) error { func (dst *Box) Scan(src any) error {
if src == nil { if src == nil {
*dst = Box{} *dst = Box{}
return nil return nil
@@ -71,7 +71,7 @@ func (BoxCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (BoxCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (BoxCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(BoxValuer); !ok { if _, ok := value.(BoxValuer); !ok {
return nil return nil
} }
@@ -88,7 +88,7 @@ func (BoxCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanBoxCodecBinary struct{} type encodePlanBoxCodecBinary struct{}
func (encodePlanBoxCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBoxCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
box, err := value.(BoxValuer).BoxValue() box, err := value.(BoxValuer).BoxValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -107,7 +107,7 @@ func (encodePlanBoxCodecBinary) Encode(value interface{}, buf []byte) (newBuf []
type encodePlanBoxCodecText struct{} type encodePlanBoxCodecText struct{}
func (encodePlanBoxCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBoxCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
box, err := value.(BoxValuer).BoxValue() box, err := value.(BoxValuer).BoxValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -126,7 +126,7 @@ func (encodePlanBoxCodecText) Encode(value interface{}, buf []byte) (newBuf []by
return buf, nil return buf, nil
} }
func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -146,7 +146,7 @@ func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) S
type scanPlanBinaryBoxToBoxScanner struct{} type scanPlanBinaryBoxToBoxScanner struct{}
func (scanPlanBinaryBoxToBoxScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryBoxToBoxScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BoxScanner) scanner := (dst).(BoxScanner)
if src == nil { if src == nil {
@@ -173,7 +173,7 @@ func (scanPlanBinaryBoxToBoxScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToBoxScanner struct{} type scanPlanTextAnyToBoxScanner struct{}
func (scanPlanTextAnyToBoxScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToBoxScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BoxScanner) scanner := (dst).(BoxScanner)
if src == nil { if src == nil {
@@ -224,7 +224,7 @@ func (c BoxCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src [
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c BoxCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c BoxCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+12 -12
View File
@@ -603,7 +603,7 @@ func (w byteSliceWrapper) UUIDValue() (UUID, error) {
// structWrapper implements CompositeIndexGetter for a struct. // structWrapper implements CompositeIndexGetter for a struct.
type structWrapper struct { type structWrapper struct {
s interface{} s any
exportedFields []reflect.Value exportedFields []reflect.Value
} }
@@ -611,7 +611,7 @@ func (w structWrapper) IsNull() bool {
return w.s == nil return w.s == nil
} }
func (w structWrapper) Index(i int) interface{} { func (w structWrapper) Index(i int) any {
if i >= len(w.exportedFields) { if i >= len(w.exportedFields) {
return fmt.Errorf("%#v only has %d public fields - %d is out of bounds", w.s, len(w.exportedFields), i) return fmt.Errorf("%#v only has %d public fields - %d is out of bounds", w.s, len(w.exportedFields), i)
} }
@@ -621,7 +621,7 @@ func (w structWrapper) Index(i int) interface{} {
// ptrStructWrapper implements CompositeIndexScanner for a pointer to a struct. // ptrStructWrapper implements CompositeIndexScanner for a pointer to a struct.
type ptrStructWrapper struct { type ptrStructWrapper struct {
s interface{} s any
exportedFields []reflect.Value exportedFields []reflect.Value
} }
@@ -629,7 +629,7 @@ func (w *ptrStructWrapper) ScanNull() error {
return fmt.Errorf("cannot scan NULL into %#v", w.s) return fmt.Errorf("cannot scan NULL into %#v", w.s)
} }
func (w *ptrStructWrapper) ScanIndex(i int) interface{} { func (w *ptrStructWrapper) ScanIndex(i int) any {
if i >= len(w.exportedFields) { if i >= len(w.exportedFields) {
return fmt.Errorf("%#v only has %d public fields - %d is out of bounds", w.s, len(w.exportedFields), i) return fmt.Errorf("%#v only has %d public fields - %d is out of bounds", w.s, len(w.exportedFields), i)
} }
@@ -649,11 +649,11 @@ func (a anySliceArray) Dimensions() []ArrayDimension {
return []ArrayDimension{{Length: int32(a.slice.Len()), LowerBound: 1}} return []ArrayDimension{{Length: int32(a.slice.Len()), LowerBound: 1}}
} }
func (a anySliceArray) Index(i int) interface{} { func (a anySliceArray) Index(i int) any {
return a.slice.Index(i).Interface() return a.slice.Index(i).Interface()
} }
func (a anySliceArray) IndexType() interface{} { func (a anySliceArray) IndexType() any {
return reflect.New(a.slice.Type().Elem()).Elem().Interface() return reflect.New(a.slice.Type().Elem()).Elem().Interface()
} }
@@ -671,11 +671,11 @@ func (a *anySliceArray) SetDimensions(dimensions []ArrayDimension) error {
return nil return nil
} }
func (a *anySliceArray) ScanIndex(i int) interface{} { func (a *anySliceArray) ScanIndex(i int) any {
return a.slice.Index(i).Addr().Interface() return a.slice.Index(i).Addr().Interface()
} }
func (a *anySliceArray) ScanIndexType() interface{} { func (a *anySliceArray) ScanIndexType() any {
return reflect.New(a.slice.Type().Elem()).Interface() return reflect.New(a.slice.Type().Elem()).Interface()
} }
@@ -706,7 +706,7 @@ func (a *anyMultiDimSliceArray) Dimensions() []ArrayDimension {
return a.dims return a.dims
} }
func (a *anyMultiDimSliceArray) Index(i int) interface{} { func (a *anyMultiDimSliceArray) Index(i int) any {
if len(a.dims) == 1 { if len(a.dims) == 1 {
return a.slice.Index(i).Interface() return a.slice.Index(i).Interface()
} }
@@ -726,7 +726,7 @@ func (a *anyMultiDimSliceArray) Index(i int) interface{} {
return v.Interface() return v.Interface()
} }
func (a *anyMultiDimSliceArray) IndexType() interface{} { func (a *anyMultiDimSliceArray) IndexType() any {
lowestSliceType := a.slice.Type() lowestSliceType := a.slice.Type()
for ; lowestSliceType.Elem().Kind() == reflect.Slice; lowestSliceType = lowestSliceType.Elem() { for ; lowestSliceType.Elem().Kind() == reflect.Slice; lowestSliceType = lowestSliceType.Elem() {
} }
@@ -794,11 +794,11 @@ func (a *anyMultiDimSliceArray) makeMultidimensionalSlice(sliceType reflect.Type
return slice return slice
} }
func (a *anyMultiDimSliceArray) ScanIndex(i int) interface{} { func (a *anyMultiDimSliceArray) ScanIndex(i int) any {
return a.slice.Index(i).Addr().Interface() return a.slice.Index(i).Addr().Interface()
} }
func (a *anyMultiDimSliceArray) ScanIndexType() interface{} { func (a *anyMultiDimSliceArray) ScanIndexType() any {
lowestSliceType := a.slice.Type() lowestSliceType := a.slice.Type()
for ; lowestSliceType.Elem().Kind() == reflect.Slice; lowestSliceType = lowestSliceType.Elem() { for ; lowestSliceType.Elem().Kind() == reflect.Slice; lowestSliceType = lowestSliceType.Elem() {
} }
+12 -12
View File
@@ -50,7 +50,7 @@ type UndecodedBytes []byte
type scanPlanAnyToUndecodedBytes struct{} type scanPlanAnyToUndecodedBytes struct{}
func (scanPlanAnyToUndecodedBytes) Scan(src []byte, dst interface{}) error { func (scanPlanAnyToUndecodedBytes) Scan(src []byte, dst any) error {
dstBuf := dst.(*UndecodedBytes) dstBuf := dst.(*UndecodedBytes)
if src == nil { if src == nil {
*dstBuf = nil *dstBuf = nil
@@ -72,7 +72,7 @@ func (ByteaCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (ByteaCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (ByteaCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -95,7 +95,7 @@ func (ByteaCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}
type encodePlanBytesCodecBinaryBytes struct{} type encodePlanBytesCodecBinaryBytes struct{}
func (encodePlanBytesCodecBinaryBytes) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBytesCodecBinaryBytes) Encode(value any, buf []byte) (newBuf []byte, err error) {
b := value.([]byte) b := value.([]byte)
if b == nil { if b == nil {
return nil, nil return nil, nil
@@ -106,7 +106,7 @@ func (encodePlanBytesCodecBinaryBytes) Encode(value interface{}, buf []byte) (ne
type encodePlanBytesCodecBinaryBytesValuer struct{} type encodePlanBytesCodecBinaryBytesValuer struct{}
func (encodePlanBytesCodecBinaryBytesValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBytesCodecBinaryBytesValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
b, err := value.(BytesValuer).BytesValue() b, err := value.(BytesValuer).BytesValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -120,7 +120,7 @@ func (encodePlanBytesCodecBinaryBytesValuer) Encode(value interface{}, buf []byt
type encodePlanBytesCodecTextBytes struct{} type encodePlanBytesCodecTextBytes struct{}
func (encodePlanBytesCodecTextBytes) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBytesCodecTextBytes) Encode(value any, buf []byte) (newBuf []byte, err error) {
b := value.([]byte) b := value.([]byte)
if b == nil { if b == nil {
return nil, nil return nil, nil
@@ -133,7 +133,7 @@ func (encodePlanBytesCodecTextBytes) Encode(value interface{}, buf []byte) (newB
type encodePlanBytesCodecTextBytesValuer struct{} type encodePlanBytesCodecTextBytesValuer struct{}
func (encodePlanBytesCodecTextBytesValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanBytesCodecTextBytesValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
b, err := value.(BytesValuer).BytesValue() b, err := value.(BytesValuer).BytesValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -147,7 +147,7 @@ func (encodePlanBytesCodecTextBytesValuer) Encode(value interface{}, buf []byte)
return buf, nil return buf, nil
} }
func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -171,7 +171,7 @@ func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryBytesToBytes struct{} type scanPlanBinaryBytesToBytes struct{}
func (scanPlanBinaryBytesToBytes) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryBytesToBytes) Scan(src []byte, dst any) error {
dstBuf := dst.(*[]byte) dstBuf := dst.(*[]byte)
if src == nil { if src == nil {
*dstBuf = nil *dstBuf = nil
@@ -185,14 +185,14 @@ func (scanPlanBinaryBytesToBytes) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryBytesToBytesScanner struct{} type scanPlanBinaryBytesToBytesScanner struct{}
func (scanPlanBinaryBytesToBytesScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryBytesToBytesScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BytesScanner) scanner := (dst).(BytesScanner)
return scanner.ScanBytes(src) return scanner.ScanBytes(src)
} }
type scanPlanTextByteaToBytes struct{} type scanPlanTextByteaToBytes struct{}
func (scanPlanTextByteaToBytes) Scan(src []byte, dst interface{}) error { func (scanPlanTextByteaToBytes) Scan(src []byte, dst any) error {
dstBuf := dst.(*[]byte) dstBuf := dst.(*[]byte)
if src == nil { if src == nil {
*dstBuf = nil *dstBuf = nil
@@ -210,7 +210,7 @@ func (scanPlanTextByteaToBytes) Scan(src []byte, dst interface{}) error {
type scanPlanTextByteaToBytesScanner struct{} type scanPlanTextByteaToBytesScanner struct{}
func (scanPlanTextByteaToBytesScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextByteaToBytesScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BytesScanner) scanner := (dst).(BytesScanner)
buf, err := decodeHexBytea(src) buf, err := decodeHexBytea(src)
if err != nil { if err != nil {
@@ -241,7 +241,7 @@ func (c ByteaCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c ByteaCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c ByteaCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func isExpectedEqBytes(a interface{}) func(interface{}) bool { func isExpectedEqBytes(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
ab := a.([]byte) ab := a.([]byte)
vb := v.([]byte) vb := v.([]byte)
+8 -8
View File
@@ -35,7 +35,7 @@ func (c Circle) CircleValue() (Circle, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Circle) Scan(src interface{}) error { func (dst *Circle) Scan(src any) error {
if src == nil { if src == nil {
*dst = Circle{} *dst = Circle{}
return nil return nil
@@ -72,7 +72,7 @@ func (CircleCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (CircleCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (CircleCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(CircleValuer); !ok { if _, ok := value.(CircleValuer); !ok {
return nil return nil
} }
@@ -89,7 +89,7 @@ func (CircleCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{
type encodePlanCircleCodecBinary struct{} type encodePlanCircleCodecBinary struct{}
func (encodePlanCircleCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanCircleCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
circle, err := value.(CircleValuer).CircleValue() circle, err := value.(CircleValuer).CircleValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -107,7 +107,7 @@ func (encodePlanCircleCodecBinary) Encode(value interface{}, buf []byte) (newBuf
type encodePlanCircleCodecText struct{} type encodePlanCircleCodecText struct{}
func (encodePlanCircleCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanCircleCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
circle, err := value.(CircleValuer).CircleValue() circle, err := value.(CircleValuer).CircleValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -125,7 +125,7 @@ func (encodePlanCircleCodecText) Encode(value interface{}, buf []byte) (newBuf [
return buf, nil return buf, nil
} }
func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -146,7 +146,7 @@ func (c CircleCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c CircleCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c CircleCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -161,7 +161,7 @@ func (c CircleCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (
type scanPlanBinaryCircleToCircleScanner struct{} type scanPlanBinaryCircleToCircleScanner struct{}
func (scanPlanBinaryCircleToCircleScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryCircleToCircleScanner) Scan(src []byte, dst any) error {
scanner := (dst).(CircleScanner) scanner := (dst).(CircleScanner)
if src == nil { if src == nil {
@@ -185,7 +185,7 @@ func (scanPlanBinaryCircleToCircleScanner) Scan(src []byte, dst interface{}) err
type scanPlanTextAnyToCircleScanner struct{} type scanPlanTextAnyToCircleScanner struct{}
func (scanPlanTextAnyToCircleScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToCircleScanner) Scan(src []byte, dst any) error {
scanner := (dst).(CircleScanner) scanner := (dst).(CircleScanner)
if src == nil { if src == nil {
+18 -18
View File
@@ -16,7 +16,7 @@ type CompositeIndexGetter interface {
IsNull() bool IsNull() bool
// Index returns the element at i. // Index returns the element at i.
Index(i int) interface{} Index(i int) any
} }
// CompositeIndexScanner is a type accessed by index that can be scanned from a PostgreSQL composite. // CompositeIndexScanner is a type accessed by index that can be scanned from a PostgreSQL composite.
@@ -25,7 +25,7 @@ type CompositeIndexScanner interface {
ScanNull() error ScanNull() error
// ScanIndex returns a value usable as a scan target for i. // ScanIndex returns a value usable as a scan target for i.
ScanIndex(i int) interface{} ScanIndex(i int) any
} }
type CompositeCodecField struct { type CompositeCodecField struct {
@@ -54,7 +54,7 @@ func (c *CompositeCodec) PreferredFormat() int16 {
return TextFormatCode return TextFormatCode
} }
func (c *CompositeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (c *CompositeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(CompositeIndexGetter); !ok { if _, ok := value.(CompositeIndexGetter); !ok {
return nil return nil
} }
@@ -74,7 +74,7 @@ type encodePlanCompositeCodecCompositeIndexGetterToBinary struct {
m *Map m *Map
} }
func (plan *encodePlanCompositeCodecCompositeIndexGetterToBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *encodePlanCompositeCodecCompositeIndexGetterToBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
getter := value.(CompositeIndexGetter) getter := value.(CompositeIndexGetter)
if getter.IsNull() { if getter.IsNull() {
@@ -94,7 +94,7 @@ type encodePlanCompositeCodecCompositeIndexGetterToText struct {
m *Map m *Map
} }
func (plan *encodePlanCompositeCodecCompositeIndexGetterToText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *encodePlanCompositeCodecCompositeIndexGetterToText) Encode(value any, buf []byte) (newBuf []byte, err error) {
getter := value.(CompositeIndexGetter) getter := value.(CompositeIndexGetter)
if getter.IsNull() { if getter.IsNull() {
@@ -109,7 +109,7 @@ func (plan *encodePlanCompositeCodecCompositeIndexGetterToText) Encode(value int
return b.Finish() return b.Finish()
} }
func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -131,7 +131,7 @@ type scanPlanBinaryCompositeToCompositeIndexScanner struct {
m *Map m *Map
} }
func (plan *scanPlanBinaryCompositeToCompositeIndexScanner) Scan(src []byte, target interface{}) error { func (plan *scanPlanBinaryCompositeToCompositeIndexScanner) Scan(src []byte, target any) error {
targetScanner := (target).(CompositeIndexScanner) targetScanner := (target).(CompositeIndexScanner)
if src == nil { if src == nil {
@@ -170,7 +170,7 @@ type scanPlanTextCompositeToCompositeIndexScanner struct {
m *Map m *Map
} }
func (plan *scanPlanTextCompositeToCompositeIndexScanner) Scan(src []byte, target interface{}) error { func (plan *scanPlanTextCompositeToCompositeIndexScanner) Scan(src []byte, target any) error {
targetScanner := (target).(CompositeIndexScanner) targetScanner := (target).(CompositeIndexScanner)
if src == nil { if src == nil {
@@ -221,7 +221,7 @@ func (c *CompositeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16
} }
} }
func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -229,9 +229,9 @@ func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byt
switch format { switch format {
case TextFormatCode: case TextFormatCode:
scanner := NewCompositeTextScanner(m, src) scanner := NewCompositeTextScanner(m, src)
values := make(map[string]interface{}, len(c.Fields)) values := make(map[string]any, len(c.Fields))
for i := 0; scanner.Next() && i < len(c.Fields); i++ { for i := 0; scanner.Next() && i < len(c.Fields); i++ {
var v interface{} var v any
fieldPlan := m.PlanScan(c.Fields[i].Type.OID, TextFormatCode, &v) fieldPlan := m.PlanScan(c.Fields[i].Type.OID, TextFormatCode, &v)
if fieldPlan == nil { if fieldPlan == nil {
return nil, fmt.Errorf("unable to scan OID %d in text format into %v", c.Fields[i].Type.OID, v) return nil, fmt.Errorf("unable to scan OID %d in text format into %v", c.Fields[i].Type.OID, v)
@@ -252,9 +252,9 @@ func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byt
return values, nil return values, nil
case BinaryFormatCode: case BinaryFormatCode:
scanner := NewCompositeBinaryScanner(m, src) scanner := NewCompositeBinaryScanner(m, src)
values := make(map[string]interface{}, len(c.Fields)) values := make(map[string]any, len(c.Fields))
for i := 0; scanner.Next() && i < len(c.Fields); i++ { for i := 0; scanner.Next() && i < len(c.Fields); i++ {
var v interface{} var v any
fieldPlan := m.PlanScan(scanner.OID(), BinaryFormatCode, &v) fieldPlan := m.PlanScan(scanner.OID(), BinaryFormatCode, &v)
if fieldPlan == nil { if fieldPlan == nil {
return nil, fmt.Errorf("unable to scan OID %d in binary format into %v", scanner.OID(), v) return nil, fmt.Errorf("unable to scan OID %d in binary format into %v", scanner.OID(), v)
@@ -472,7 +472,7 @@ func NewCompositeBinaryBuilder(m *Map, buf []byte) *CompositeBinaryBuilder {
return &CompositeBinaryBuilder{m: m, buf: buf, startIdx: startIdx} return &CompositeBinaryBuilder{m: m, buf: buf, startIdx: startIdx}
} }
func (b *CompositeBinaryBuilder) AppendValue(oid uint32, field interface{}) { func (b *CompositeBinaryBuilder) AppendValue(oid uint32, field any) {
if b.err != nil { if b.err != nil {
return return
} }
@@ -529,7 +529,7 @@ func NewCompositeTextBuilder(m *Map, buf []byte) *CompositeTextBuilder {
return &CompositeTextBuilder{m: m, buf: buf} return &CompositeTextBuilder{m: m, buf: buf}
} }
func (b *CompositeTextBuilder) AppendValue(oid uint32, field interface{}) { func (b *CompositeTextBuilder) AppendValue(oid uint32, field any) {
if b.err != nil { if b.err != nil {
return return
} }
@@ -581,7 +581,7 @@ func quoteCompositeFieldIfNeeded(src string) string {
// CompositeFields represents the values of a composite value. It can be used as an encoding source or as a scan target. // CompositeFields represents the values of a composite value. It can be used as an encoding source or as a scan target.
// It cannot scan a NULL, but the composite fields can be NULL. // It cannot scan a NULL, but the composite fields can be NULL.
type CompositeFields []interface{} type CompositeFields []any
func (cf CompositeFields) SkipUnderlyingTypePlan() {} func (cf CompositeFields) SkipUnderlyingTypePlan() {}
@@ -589,7 +589,7 @@ func (cf CompositeFields) IsNull() bool {
return cf == nil return cf == nil
} }
func (cf CompositeFields) Index(i int) interface{} { func (cf CompositeFields) Index(i int) any {
return cf[i] return cf[i]
} }
@@ -597,6 +597,6 @@ func (cf CompositeFields) ScanNull() error {
return fmt.Errorf("cannot scan NULL into CompositeFields") return fmt.Errorf("cannot scan NULL into CompositeFields")
} }
func (cf CompositeFields) ScanIndex(i int) interface{} { func (cf CompositeFields) ScanIndex(i int) any {
return cf[i] return cf[i]
} }
+3 -3
View File
@@ -60,7 +60,7 @@ func (p point3d) IsNull() bool {
return false return false
} }
func (p point3d) Index(i int) interface{} { func (p point3d) Index(i int) any {
switch i { switch i {
case 0: case 0:
return p.X return p.X
@@ -77,7 +77,7 @@ func (p *point3d) ScanNull() error {
return fmt.Errorf("cannot scan NULL into point3d") return fmt.Errorf("cannot scan NULL into point3d")
} }
func (p *point3d) ScanIndex(i int) interface{} { func (p *point3d) ScanIndex(i int) any {
switch i { switch i {
case 0: case 0:
return &p.X return &p.X
@@ -202,7 +202,7 @@ create type point3d as (
values, err := rows.Values() values, err := rows.Values()
require.NoErrorf(t, err, "%v", format.name) require.NoErrorf(t, err, "%v", format.name)
require.Lenf(t, values, 1, "%v", format.name) require.Lenf(t, values, 1, "%v", format.name)
require.Equalf(t, map[string]interface{}{"x": 1.0, "y": 2.0, "z": 3.0}, values[0], "%v", format.name) require.Equalf(t, map[string]any{"x": 1.0, "y": 2.0, "z": 3.0}, values[0], "%v", format.name)
require.False(t, rows.Next()) require.False(t, rows.Next())
require.NoErrorf(t, rows.Err(), "%v", format.name) require.NoErrorf(t, rows.Err(), "%v", format.name)
} }
+13 -13
View File
@@ -15,7 +15,7 @@ const (
) )
// underlyingNumberType gets the underlying type that can be converted to Int2, Int4, Int8, Float4, or Float8 // underlyingNumberType gets the underlying type that can be converted to Int2, Int4, Int8, Float4, or Float8
func underlyingNumberType(val interface{}) (interface{}, bool) { func underlyingNumberType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -70,7 +70,7 @@ func underlyingNumberType(val interface{}) (interface{}, bool) {
} }
// underlyingBoolType gets the underlying type that can be converted to Bool // underlyingBoolType gets the underlying type that can be converted to Bool
func underlyingBoolType(val interface{}) (interface{}, bool) { func underlyingBoolType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -89,7 +89,7 @@ func underlyingBoolType(val interface{}) (interface{}, bool) {
} }
// underlyingBytesType gets the underlying type that can be converted to []byte // underlyingBytesType gets the underlying type that can be converted to []byte
func underlyingBytesType(val interface{}) (interface{}, bool) { func underlyingBytesType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -110,7 +110,7 @@ func underlyingBytesType(val interface{}) (interface{}, bool) {
} }
// underlyingStringType gets the underlying type that can be converted to String // underlyingStringType gets the underlying type that can be converted to String
func underlyingStringType(val interface{}) (interface{}, bool) { func underlyingStringType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -129,7 +129,7 @@ func underlyingStringType(val interface{}) (interface{}, bool) {
} }
// underlyingPtrType dereferences a pointer // underlyingPtrType dereferences a pointer
func underlyingPtrType(val interface{}) (interface{}, bool) { func underlyingPtrType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -145,7 +145,7 @@ func underlyingPtrType(val interface{}) (interface{}, bool) {
} }
// underlyingTimeType gets the underlying type that can be converted to time.Time // underlyingTimeType gets the underlying type that can be converted to time.Time
func underlyingTimeType(val interface{}) (interface{}, bool) { func underlyingTimeType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -166,7 +166,7 @@ func underlyingTimeType(val interface{}) (interface{}, bool) {
} }
// underlyingUUIDType gets the underlying type that can be converted to [16]byte // underlyingUUIDType gets the underlying type that can be converted to [16]byte
func underlyingUUIDType(val interface{}) (interface{}, bool) { func underlyingUUIDType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -187,7 +187,7 @@ func underlyingUUIDType(val interface{}) (interface{}, bool) {
} }
// underlyingSliceType gets the underlying slice type // underlyingSliceType gets the underlying slice type
func underlyingSliceType(val interface{}) (interface{}, bool) { func underlyingSliceType(val any) (any, bool) {
refVal := reflect.ValueOf(val) refVal := reflect.ValueOf(val)
switch refVal.Kind() { switch refVal.Kind() {
@@ -208,7 +208,7 @@ func underlyingSliceType(val interface{}) (interface{}, bool) {
return nil, false return nil, false
} }
func int64AssignTo(srcVal int64, srcValid bool, dst interface{}) error { func int64AssignTo(srcVal int64, srcValid bool, dst any) error {
if srcValid { if srcValid {
switch v := dst.(type) { switch v := dst.(type) {
case *int: case *int:
@@ -326,7 +326,7 @@ func int64AssignTo(srcVal int64, srcValid bool, dst interface{}) error {
return fmt.Errorf("cannot assign %v %v into %T", srcVal, srcValid, dst) return fmt.Errorf("cannot assign %v %v into %T", srcVal, srcValid, dst)
} }
func float64AssignTo(srcVal float64, srcValid bool, dst interface{}) error { func float64AssignTo(srcVal float64, srcValid bool, dst any) error {
if srcValid { if srcValid {
switch v := dst.(type) { switch v := dst.(type) {
case *float32: case *float32:
@@ -368,7 +368,7 @@ func float64AssignTo(srcVal float64, srcValid bool, dst interface{}) error {
return fmt.Errorf("cannot assign %v %v into %T", srcVal, srcValid, dst) return fmt.Errorf("cannot assign %v %v into %T", srcVal, srcValid, dst)
} }
func NullAssignTo(dst interface{}) error { func NullAssignTo(dst any) error {
dstPtr := reflect.ValueOf(dst) dstPtr := reflect.ValueOf(dst)
// AssignTo dst must always be a pointer // AssignTo dst must always be a pointer
@@ -389,7 +389,7 @@ func NullAssignTo(dst interface{}) error {
var kindTypes map[reflect.Kind]reflect.Type var kindTypes map[reflect.Kind]reflect.Type
func toInterface(dst reflect.Value, t reflect.Type) (interface{}, bool) { func toInterface(dst reflect.Value, t reflect.Type) (any, bool) {
nextDst := dst.Convert(t) nextDst := dst.Convert(t)
return nextDst.Interface(), dst.Type() != nextDst.Type() return nextDst.Interface(), dst.Type() != nextDst.Type()
} }
@@ -401,7 +401,7 @@ func toInterface(dst reflect.Value, t reflect.Type) (interface{}, bool) {
// //
// GetAssignToDstType returns the converted dst and a bool representing if any // GetAssignToDstType returns the converted dst and a bool representing if any
// change was made. // change was made.
func GetAssignToDstType(dst interface{}) (interface{}, bool) { func GetAssignToDstType(dst any) (any, bool) {
dstPtr := reflect.ValueOf(dst) dstPtr := reflect.ValueOf(dst)
// AssignTo dst must always be a pointer // AssignTo dst must always be a pointer
+8 -8
View File
@@ -40,7 +40,7 @@ const (
) )
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Date) Scan(src interface{}) error { func (dst *Date) Scan(src any) error {
if src == nil { if src == nil {
*dst = Date{} *dst = Date{}
return nil return nil
@@ -127,7 +127,7 @@ func (DateCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (DateCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (DateCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(DateValuer); !ok { if _, ok := value.(DateValuer); !ok {
return nil return nil
} }
@@ -144,7 +144,7 @@ func (DateCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanDateCodecBinary struct{} type encodePlanDateCodecBinary struct{}
func (encodePlanDateCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanDateCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
date, err := value.(DateValuer).DateValue() date, err := value.(DateValuer).DateValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -173,7 +173,7 @@ func (encodePlanDateCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanDateCodecText struct{} type encodePlanDateCodecText struct{}
func (encodePlanDateCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanDateCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
date, err := value.(DateValuer).DateValue() date, err := value.(DateValuer).DateValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -211,7 +211,7 @@ func (encodePlanDateCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil return buf, nil
} }
func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -231,7 +231,7 @@ func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryDateToDateScanner struct{} type scanPlanBinaryDateToDateScanner struct{}
func (scanPlanBinaryDateToDateScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryDateToDateScanner) Scan(src []byte, dst any) error {
scanner := (dst).(DateScanner) scanner := (dst).(DateScanner)
if src == nil { if src == nil {
@@ -257,7 +257,7 @@ func (scanPlanBinaryDateToDateScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToDateScanner struct{} type scanPlanTextAnyToDateScanner struct{}
func (scanPlanTextAnyToDateScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToDateScanner) Scan(src []byte, dst any) error {
scanner := (dst).(DateScanner) scanner := (dst).(DateScanner)
if src == nil { if src == nil {
@@ -301,7 +301,7 @@ func (c DateCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqTime(a interface{}) func(interface{}) bool { func isExpectedEqTime(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
at := a.(time.Time) at := a.(time.Time)
vt := v.(time.Time) vt := v.(time.Time)
+5 -5
View File
@@ -20,7 +20,7 @@ func (EnumCodec) PreferredFormat() int16 {
return TextFormatCode return TextFormatCode
} }
func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case TextFormatCode, BinaryFormatCode: case TextFormatCode, BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -38,7 +38,7 @@ func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
return nil return nil
} }
func (c *EnumCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (c *EnumCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case TextFormatCode, BinaryFormatCode: case TextFormatCode, BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -60,7 +60,7 @@ func (c *EnumCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return c.DecodeValue(m, oid, format, src) return c.DecodeValue(m, oid, format, src)
} }
func (c *EnumCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c *EnumCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -87,7 +87,7 @@ type scanPlanTextAnyToEnumString struct {
codec *EnumCodec codec *EnumCodec
} }
func (plan *scanPlanTextAnyToEnumString) Scan(src []byte, dst interface{}) error { func (plan *scanPlanTextAnyToEnumString) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -102,7 +102,7 @@ type scanPlanTextAnyToEnumTextScanner struct {
codec *EnumCodec codec *EnumCodec
} }
func (plan *scanPlanTextAnyToEnumTextScanner) Scan(src []byte, dst interface{}) error { func (plan *scanPlanTextAnyToEnumTextScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TextScanner) scanner := (dst).(TextScanner)
if src == nil { if src == nil {
+1 -1
View File
@@ -64,6 +64,6 @@ create type enum_test as enum ('foo', 'bar', 'baz');`)
require.True(t, rows.Next()) require.True(t, rows.Next())
values, err := rows.Values() values, err := rows.Values()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, values, []interface{}{"foo"}) require.Equal(t, values, []any{"foo"})
}) })
} }
+13 -13
View File
@@ -35,7 +35,7 @@ func (f Float4) Int64Value() (Int8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (f *Float4) Scan(src interface{}) error { func (f *Float4) Scan(src any) error {
if src == nil { if src == nil {
*f = Float4{} *f = Float4{}
return nil return nil
@@ -75,7 +75,7 @@ func (Float4Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Float4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Float4Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -102,21 +102,21 @@ func (Float4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{
type encodePlanFloat4CodecBinaryFloat32 struct{} type encodePlanFloat4CodecBinaryFloat32 struct{}
func (encodePlanFloat4CodecBinaryFloat32) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanFloat4CodecBinaryFloat32) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(float32) n := value.(float32)
return pgio.AppendUint32(buf, math.Float32bits(n)), nil return pgio.AppendUint32(buf, math.Float32bits(n)), nil
} }
type encodePlanTextFloat32 struct{} type encodePlanTextFloat32 struct{}
func (encodePlanTextFloat32) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextFloat32) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(float32) n := value.(float32)
return append(buf, strconv.FormatFloat(float64(n), 'f', -1, 32)...), nil return append(buf, strconv.FormatFloat(float64(n), 'f', -1, 32)...), nil
} }
type encodePlanFloat4CodecBinaryFloat64Valuer struct{} type encodePlanFloat4CodecBinaryFloat64Valuer struct{}
func (encodePlanFloat4CodecBinaryFloat64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanFloat4CodecBinaryFloat64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Float64Valuer).Float64Value() n, err := value.(Float64Valuer).Float64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -131,7 +131,7 @@ func (encodePlanFloat4CodecBinaryFloat64Valuer) Encode(value interface{}, buf []
type encodePlanFloat4CodecBinaryInt64Valuer struct{} type encodePlanFloat4CodecBinaryInt64Valuer struct{}
func (encodePlanFloat4CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanFloat4CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -145,7 +145,7 @@ func (encodePlanFloat4CodecBinaryInt64Valuer) Encode(value interface{}, buf []by
return pgio.AppendUint32(buf, math.Float32bits(f)), nil return pgio.AppendUint32(buf, math.Float32bits(f)), nil
} }
func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -175,7 +175,7 @@ func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}
type scanPlanBinaryFloat4ToFloat32 struct{} type scanPlanBinaryFloat4ToFloat32 struct{}
func (scanPlanBinaryFloat4ToFloat32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat4ToFloat32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -193,7 +193,7 @@ func (scanPlanBinaryFloat4ToFloat32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryFloat4ToFloat64Scanner struct{} type scanPlanBinaryFloat4ToFloat64Scanner struct{}
func (scanPlanBinaryFloat4ToFloat64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat4ToFloat64Scanner) Scan(src []byte, dst any) error {
s := (dst).(Float64Scanner) s := (dst).(Float64Scanner)
if src == nil { if src == nil {
@@ -210,7 +210,7 @@ func (scanPlanBinaryFloat4ToFloat64Scanner) Scan(src []byte, dst interface{}) er
type scanPlanBinaryFloat4ToInt64Scanner struct{} type scanPlanBinaryFloat4ToInt64Scanner struct{}
func (scanPlanBinaryFloat4ToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat4ToInt64Scanner) Scan(src []byte, dst any) error {
s := (dst).(Int64Scanner) s := (dst).(Int64Scanner)
if src == nil { if src == nil {
@@ -233,7 +233,7 @@ func (scanPlanBinaryFloat4ToInt64Scanner) Scan(src []byte, dst interface{}) erro
type scanPlanBinaryFloat4ToTextScanner struct{} type scanPlanBinaryFloat4ToTextScanner struct{}
func (scanPlanBinaryFloat4ToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat4ToTextScanner) Scan(src []byte, dst any) error {
s := (dst).(TextScanner) s := (dst).(TextScanner)
if src == nil { if src == nil {
@@ -252,7 +252,7 @@ func (scanPlanBinaryFloat4ToTextScanner) Scan(src []byte, dst interface{}) error
type scanPlanTextAnyToFloat32 struct{} type scanPlanTextAnyToFloat32 struct{}
func (scanPlanTextAnyToFloat32) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToFloat32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -281,7 +281,7 @@ func (c Float4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
return n, nil return n, nil
} }
func (c Float4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Float4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+16 -16
View File
@@ -43,7 +43,7 @@ func (f Float8) Int64Value() (Int8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (f *Float8) Scan(src interface{}) error { func (f *Float8) Scan(src any) error {
if src == nil { if src == nil {
*f = Float8{} *f = Float8{}
return nil return nil
@@ -83,7 +83,7 @@ func (Float8Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -110,21 +110,21 @@ func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{
type encodePlanFloat8CodecBinaryFloat64 struct{} type encodePlanFloat8CodecBinaryFloat64 struct{}
func (encodePlanFloat8CodecBinaryFloat64) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanFloat8CodecBinaryFloat64) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(float64) n := value.(float64)
return pgio.AppendUint64(buf, math.Float64bits(n)), nil return pgio.AppendUint64(buf, math.Float64bits(n)), nil
} }
type encodePlanTextFloat64 struct{} type encodePlanTextFloat64 struct{}
func (encodePlanTextFloat64) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextFloat64) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(float64) n := value.(float64)
return append(buf, strconv.FormatFloat(n, 'f', -1, 64)...), nil return append(buf, strconv.FormatFloat(n, 'f', -1, 64)...), nil
} }
type encodePlanFloat8CodecBinaryFloat64Valuer struct{} type encodePlanFloat8CodecBinaryFloat64Valuer struct{}
func (encodePlanFloat8CodecBinaryFloat64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanFloat8CodecBinaryFloat64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Float64Valuer).Float64Value() n, err := value.(Float64Valuer).Float64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -139,7 +139,7 @@ func (encodePlanFloat8CodecBinaryFloat64Valuer) Encode(value interface{}, buf []
type encodePlanTextFloat64Valuer struct{} type encodePlanTextFloat64Valuer struct{}
func (encodePlanTextFloat64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextFloat64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Float64Valuer).Float64Value() n, err := value.(Float64Valuer).Float64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -154,7 +154,7 @@ func (encodePlanTextFloat64Valuer) Encode(value interface{}, buf []byte) (newBuf
type encodePlanFloat8CodecBinaryInt64Valuer struct{} type encodePlanFloat8CodecBinaryInt64Valuer struct{}
func (encodePlanFloat8CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanFloat8CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -170,7 +170,7 @@ func (encodePlanFloat8CodecBinaryInt64Valuer) Encode(value interface{}, buf []by
type encodePlanTextInt64Valuer struct{} type encodePlanTextInt64Valuer struct{}
func (encodePlanTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -183,7 +183,7 @@ func (encodePlanTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf [
return append(buf, strconv.FormatInt(n.Int64, 10)...), nil return append(buf, strconv.FormatInt(n.Int64, 10)...), nil
} }
func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -213,7 +213,7 @@ func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}
type scanPlanBinaryFloat8ToFloat64 struct{} type scanPlanBinaryFloat8ToFloat64 struct{}
func (scanPlanBinaryFloat8ToFloat64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat8ToFloat64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -231,7 +231,7 @@ func (scanPlanBinaryFloat8ToFloat64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryFloat8ToFloat64Scanner struct{} type scanPlanBinaryFloat8ToFloat64Scanner struct{}
func (scanPlanBinaryFloat8ToFloat64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat8ToFloat64Scanner) Scan(src []byte, dst any) error {
s := (dst).(Float64Scanner) s := (dst).(Float64Scanner)
if src == nil { if src == nil {
@@ -248,7 +248,7 @@ func (scanPlanBinaryFloat8ToFloat64Scanner) Scan(src []byte, dst interface{}) er
type scanPlanBinaryFloat8ToInt64Scanner struct{} type scanPlanBinaryFloat8ToInt64Scanner struct{}
func (scanPlanBinaryFloat8ToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat8ToInt64Scanner) Scan(src []byte, dst any) error {
s := (dst).(Int64Scanner) s := (dst).(Int64Scanner)
if src == nil { if src == nil {
@@ -271,7 +271,7 @@ func (scanPlanBinaryFloat8ToInt64Scanner) Scan(src []byte, dst interface{}) erro
type scanPlanBinaryFloat8ToTextScanner struct{} type scanPlanBinaryFloat8ToTextScanner struct{}
func (scanPlanBinaryFloat8ToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryFloat8ToTextScanner) Scan(src []byte, dst any) error {
s := (dst).(TextScanner) s := (dst).(TextScanner)
if src == nil { if src == nil {
@@ -290,7 +290,7 @@ func (scanPlanBinaryFloat8ToTextScanner) Scan(src []byte, dst interface{}) error
type scanPlanTextAnyToFloat64 struct{} type scanPlanTextAnyToFloat64 struct{}
func (scanPlanTextAnyToFloat64) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToFloat64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -308,7 +308,7 @@ func (scanPlanTextAnyToFloat64) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToFloat64Scanner struct{} type scanPlanTextAnyToFloat64Scanner struct{}
func (scanPlanTextAnyToFloat64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToFloat64Scanner) Scan(src []byte, dst any) error {
s := (dst).(Float64Scanner) s := (dst).(Float64Scanner)
if src == nil { if src == nil {
@@ -327,7 +327,7 @@ func (c Float8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
return c.DecodeValue(m, oid, format, src) return c.DecodeValue(m, oid, format, src)
} }
func (c Float8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Float8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+8 -8
View File
@@ -35,7 +35,7 @@ func (h Hstore) HstoreValue() (Hstore, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (h *Hstore) Scan(src interface{}) error { func (h *Hstore) Scan(src any) error {
if src == nil { if src == nil {
*h = nil *h = nil
return nil return nil
@@ -72,7 +72,7 @@ func (HstoreCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (HstoreCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (HstoreCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(HstoreValuer); !ok { if _, ok := value.(HstoreValuer); !ok {
return nil return nil
} }
@@ -89,7 +89,7 @@ func (HstoreCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{
type encodePlanHstoreCodecBinary struct{} type encodePlanHstoreCodecBinary struct{}
func (encodePlanHstoreCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanHstoreCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
hstore, err := value.(HstoreValuer).HstoreValue() hstore, err := value.(HstoreValuer).HstoreValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -118,7 +118,7 @@ func (encodePlanHstoreCodecBinary) Encode(value interface{}, buf []byte) (newBuf
type encodePlanHstoreCodecText struct{} type encodePlanHstoreCodecText struct{}
func (encodePlanHstoreCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanHstoreCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
hstore, err := value.(HstoreValuer).HstoreValue() hstore, err := value.(HstoreValuer).HstoreValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -150,7 +150,7 @@ func (encodePlanHstoreCodecText) Encode(value interface{}, buf []byte) (newBuf [
return buf, nil return buf, nil
} }
func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -170,7 +170,7 @@ func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}
type scanPlanBinaryHstoreToHstoreScanner struct{} type scanPlanBinaryHstoreToHstoreScanner struct{}
func (scanPlanBinaryHstoreToHstoreScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryHstoreToHstoreScanner) Scan(src []byte, dst any) error {
scanner := (dst).(HstoreScanner) scanner := (dst).(HstoreScanner)
if src == nil { if src == nil {
@@ -230,7 +230,7 @@ func (scanPlanBinaryHstoreToHstoreScanner) Scan(src []byte, dst interface{}) err
type scanPlanTextAnyToHstoreScanner struct{} type scanPlanTextAnyToHstoreScanner struct{}
func (scanPlanTextAnyToHstoreScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToHstoreScanner) Scan(src []byte, dst any) error {
scanner := (dst).(HstoreScanner) scanner := (dst).(HstoreScanner)
if src == nil { if src == nil {
@@ -258,7 +258,7 @@ func (c HstoreCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c HstoreCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c HstoreCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+4 -4
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqMapStringString(a interface{}) func(interface{}) bool { func isExpectedEqMapStringString(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
am := a.(map[string]string) am := a.(map[string]string)
vm := v.(map[string]string) vm := v.(map[string]string)
@@ -28,8 +28,8 @@ func isExpectedEqMapStringString(a interface{}) func(interface{}) bool {
} }
} }
func isExpectedEqMapStringPointerString(a interface{}) func(interface{}) bool { func isExpectedEqMapStringPointerString(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
am := a.(map[string]*string) am := a.(map[string]*string)
vm := v.(map[string]*string) vm := v.(map[string]*string)
+8 -8
View File
@@ -38,7 +38,7 @@ func (inet Inet) InetValue() (Inet, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Inet) Scan(src interface{}) error { func (dst *Inet) Scan(src any) error {
if src == nil { if src == nil {
*dst = Inet{} *dst = Inet{}
return nil return nil
@@ -75,7 +75,7 @@ func (InetCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (InetCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (InetCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(InetValuer); !ok { if _, ok := value.(InetValuer); !ok {
return nil return nil
} }
@@ -92,7 +92,7 @@ func (InetCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanInetCodecBinary struct{} type encodePlanInetCodecBinary struct{}
func (encodePlanInetCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInetCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
inet, err := value.(InetValuer).InetValue() inet, err := value.(InetValuer).InetValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -127,7 +127,7 @@ func (encodePlanInetCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanInetCodecText struct{} type encodePlanInetCodecText struct{}
func (encodePlanInetCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInetCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
inet, err := value.(InetValuer).InetValue() inet, err := value.(InetValuer).InetValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -140,7 +140,7 @@ func (encodePlanInetCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return append(buf, inet.IPNet.String()...), nil return append(buf, inet.IPNet.String()...), nil
} }
func (InetCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (InetCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -162,7 +162,7 @@ func (c InetCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c InetCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c InetCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -182,7 +182,7 @@ func (c InetCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanBinaryInetToInetScanner struct{} type scanPlanBinaryInetToInetScanner struct{}
func (scanPlanBinaryInetToInetScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInetToInetScanner) Scan(src []byte, dst any) error {
scanner := (dst).(InetScanner) scanner := (dst).(InetScanner)
if src == nil { if src == nil {
@@ -211,7 +211,7 @@ func (scanPlanBinaryInetToInetScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInetScanner struct{} type scanPlanTextAnyToInetScanner struct{}
func (scanPlanTextAnyToInetScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInetScanner) Scan(src []byte, dst any) error {
scanner := (dst).(InetScanner) scanner := (dst).(InetScanner)
if src == nil { if src == nil {
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqIPNet(a interface{}) func(interface{}) bool { func isExpectedEqIPNet(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
ap := a.(*net.IPNet) ap := a.(*net.IPNet)
vp := v.(net.IPNet) vp := v.(net.IPNet)
+71 -71
View File
@@ -48,7 +48,7 @@ func (n Int2) Int64Value() (Int8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int2) Scan(src interface{}) error { func (dst *Int2) Scan(src any) error {
if src == nil { if src == nil {
*dst = Int2{} *dst = Int2{}
return nil return nil
@@ -127,7 +127,7 @@ func (Int2Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Int2Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Int2Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -150,21 +150,21 @@ func (Int2Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanInt2CodecBinaryInt16 struct{} type encodePlanInt2CodecBinaryInt16 struct{}
func (encodePlanInt2CodecBinaryInt16) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt2CodecBinaryInt16) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int16) n := value.(int16)
return pgio.AppendInt16(buf, int16(n)), nil return pgio.AppendInt16(buf, int16(n)), nil
} }
type encodePlanInt2CodecTextInt16 struct{} type encodePlanInt2CodecTextInt16 struct{}
func (encodePlanInt2CodecTextInt16) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt2CodecTextInt16) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int16) n := value.(int16)
return append(buf, strconv.FormatInt(int64(n), 10)...), nil return append(buf, strconv.FormatInt(int64(n), 10)...), nil
} }
type encodePlanInt2CodecBinaryInt64Valuer struct{} type encodePlanInt2CodecBinaryInt64Valuer struct{}
func (encodePlanInt2CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt2CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -186,7 +186,7 @@ func (encodePlanInt2CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte
type encodePlanInt2CodecTextInt64Valuer struct{} type encodePlanInt2CodecTextInt64Valuer struct{}
func (encodePlanInt2CodecTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt2CodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -206,7 +206,7 @@ func (encodePlanInt2CodecTextInt64Valuer) Encode(value interface{}, buf []byte)
return append(buf, strconv.FormatInt(n.Int64, 10)...), nil return append(buf, strconv.FormatInt(n.Int64, 10)...), nil
} }
func (Int2Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Int2Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -279,7 +279,7 @@ func (c Int2Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return n, nil return n, nil
} }
func (c Int2Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Int2Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -294,7 +294,7 @@ func (c Int2Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanBinaryInt2ToInt8 struct{} type scanPlanBinaryInt2ToInt8 struct{}
func (scanPlanBinaryInt2ToInt8) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToInt8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -322,7 +322,7 @@ func (scanPlanBinaryInt2ToInt8) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToUint8 struct{} type scanPlanBinaryInt2ToUint8 struct{}
func (scanPlanBinaryInt2ToUint8) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToUint8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -352,7 +352,7 @@ func (scanPlanBinaryInt2ToUint8) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToInt16 struct{} type scanPlanBinaryInt2ToInt16 struct{}
func (scanPlanBinaryInt2ToInt16) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToInt16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -373,7 +373,7 @@ func (scanPlanBinaryInt2ToInt16) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToUint16 struct{} type scanPlanBinaryInt2ToUint16 struct{}
func (scanPlanBinaryInt2ToUint16) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToUint16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -399,7 +399,7 @@ func (scanPlanBinaryInt2ToUint16) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToInt32 struct{} type scanPlanBinaryInt2ToInt32 struct{}
func (scanPlanBinaryInt2ToInt32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToInt32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -420,7 +420,7 @@ func (scanPlanBinaryInt2ToInt32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToUint32 struct{} type scanPlanBinaryInt2ToUint32 struct{}
func (scanPlanBinaryInt2ToUint32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToUint32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -446,7 +446,7 @@ func (scanPlanBinaryInt2ToUint32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToInt64 struct{} type scanPlanBinaryInt2ToInt64 struct{}
func (scanPlanBinaryInt2ToInt64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToInt64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -467,7 +467,7 @@ func (scanPlanBinaryInt2ToInt64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToUint64 struct{} type scanPlanBinaryInt2ToUint64 struct{}
func (scanPlanBinaryInt2ToUint64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToUint64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -493,7 +493,7 @@ func (scanPlanBinaryInt2ToUint64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToInt struct{} type scanPlanBinaryInt2ToInt struct{}
func (scanPlanBinaryInt2ToInt) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToInt) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -514,7 +514,7 @@ func (scanPlanBinaryInt2ToInt) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToUint struct{} type scanPlanBinaryInt2ToUint struct{}
func (scanPlanBinaryInt2ToUint) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToUint) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -540,7 +540,7 @@ func (scanPlanBinaryInt2ToUint) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt2ToInt64Scanner struct{} type scanPlanBinaryInt2ToInt64Scanner struct{}
func (scanPlanBinaryInt2ToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner) s, ok := (dst).(Int64Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -561,7 +561,7 @@ func (scanPlanBinaryInt2ToInt64Scanner) Scan(src []byte, dst interface{}) error
type scanPlanBinaryInt2ToTextScanner struct{} type scanPlanBinaryInt2ToTextScanner struct{}
func (scanPlanBinaryInt2ToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt2ToTextScanner) Scan(src []byte, dst any) error {
s, ok := (dst).(TextScanner) s, ok := (dst).(TextScanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -608,7 +608,7 @@ func (n Int4) Int64Value() (Int8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int4) Scan(src interface{}) error { func (dst *Int4) Scan(src any) error {
if src == nil { if src == nil {
*dst = Int4{} *dst = Int4{}
return nil return nil
@@ -687,7 +687,7 @@ func (Int4Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Int4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Int4Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -710,21 +710,21 @@ func (Int4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanInt4CodecBinaryInt32 struct{} type encodePlanInt4CodecBinaryInt32 struct{}
func (encodePlanInt4CodecBinaryInt32) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt4CodecBinaryInt32) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int32) n := value.(int32)
return pgio.AppendInt32(buf, int32(n)), nil return pgio.AppendInt32(buf, int32(n)), nil
} }
type encodePlanInt4CodecTextInt32 struct{} type encodePlanInt4CodecTextInt32 struct{}
func (encodePlanInt4CodecTextInt32) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt4CodecTextInt32) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int32) n := value.(int32)
return append(buf, strconv.FormatInt(int64(n), 10)...), nil return append(buf, strconv.FormatInt(int64(n), 10)...), nil
} }
type encodePlanInt4CodecBinaryInt64Valuer struct{} type encodePlanInt4CodecBinaryInt64Valuer struct{}
func (encodePlanInt4CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt4CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -746,7 +746,7 @@ func (encodePlanInt4CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte
type encodePlanInt4CodecTextInt64Valuer struct{} type encodePlanInt4CodecTextInt64Valuer struct{}
func (encodePlanInt4CodecTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt4CodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -766,7 +766,7 @@ func (encodePlanInt4CodecTextInt64Valuer) Encode(value interface{}, buf []byte)
return append(buf, strconv.FormatInt(n.Int64, 10)...), nil return append(buf, strconv.FormatInt(n.Int64, 10)...), nil
} }
func (Int4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Int4Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -839,7 +839,7 @@ func (c Int4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return n, nil return n, nil
} }
func (c Int4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Int4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -854,7 +854,7 @@ func (c Int4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanBinaryInt4ToInt8 struct{} type scanPlanBinaryInt4ToInt8 struct{}
func (scanPlanBinaryInt4ToInt8) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToInt8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -882,7 +882,7 @@ func (scanPlanBinaryInt4ToInt8) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToUint8 struct{} type scanPlanBinaryInt4ToUint8 struct{}
func (scanPlanBinaryInt4ToUint8) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToUint8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -912,7 +912,7 @@ func (scanPlanBinaryInt4ToUint8) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToInt16 struct{} type scanPlanBinaryInt4ToInt16 struct{}
func (scanPlanBinaryInt4ToInt16) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToInt16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -940,7 +940,7 @@ func (scanPlanBinaryInt4ToInt16) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToUint16 struct{} type scanPlanBinaryInt4ToUint16 struct{}
func (scanPlanBinaryInt4ToUint16) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToUint16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -970,7 +970,7 @@ func (scanPlanBinaryInt4ToUint16) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToInt32 struct{} type scanPlanBinaryInt4ToInt32 struct{}
func (scanPlanBinaryInt4ToInt32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToInt32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -991,7 +991,7 @@ func (scanPlanBinaryInt4ToInt32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToUint32 struct{} type scanPlanBinaryInt4ToUint32 struct{}
func (scanPlanBinaryInt4ToUint32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToUint32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1017,7 +1017,7 @@ func (scanPlanBinaryInt4ToUint32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToInt64 struct{} type scanPlanBinaryInt4ToInt64 struct{}
func (scanPlanBinaryInt4ToInt64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToInt64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1038,7 +1038,7 @@ func (scanPlanBinaryInt4ToInt64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToUint64 struct{} type scanPlanBinaryInt4ToUint64 struct{}
func (scanPlanBinaryInt4ToUint64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToUint64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1064,7 +1064,7 @@ func (scanPlanBinaryInt4ToUint64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToInt struct{} type scanPlanBinaryInt4ToInt struct{}
func (scanPlanBinaryInt4ToInt) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToInt) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1085,7 +1085,7 @@ func (scanPlanBinaryInt4ToInt) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToUint struct{} type scanPlanBinaryInt4ToUint struct{}
func (scanPlanBinaryInt4ToUint) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToUint) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1111,7 +1111,7 @@ func (scanPlanBinaryInt4ToUint) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt4ToInt64Scanner struct{} type scanPlanBinaryInt4ToInt64Scanner struct{}
func (scanPlanBinaryInt4ToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner) s, ok := (dst).(Int64Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -1132,7 +1132,7 @@ func (scanPlanBinaryInt4ToInt64Scanner) Scan(src []byte, dst interface{}) error
type scanPlanBinaryInt4ToTextScanner struct{} type scanPlanBinaryInt4ToTextScanner struct{}
func (scanPlanBinaryInt4ToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt4ToTextScanner) Scan(src []byte, dst any) error {
s, ok := (dst).(TextScanner) s, ok := (dst).(TextScanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -1179,7 +1179,7 @@ func (n Int8) Int64Value() (Int8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int8) Scan(src interface{}) error { func (dst *Int8) Scan(src any) error {
if src == nil { if src == nil {
*dst = Int8{} *dst = Int8{}
return nil return nil
@@ -1258,7 +1258,7 @@ func (Int8Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Int8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Int8Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -1281,21 +1281,21 @@ func (Int8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanInt8CodecBinaryInt64 struct{} type encodePlanInt8CodecBinaryInt64 struct{}
func (encodePlanInt8CodecBinaryInt64) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt8CodecBinaryInt64) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int64) n := value.(int64)
return pgio.AppendInt64(buf, int64(n)), nil return pgio.AppendInt64(buf, int64(n)), nil
} }
type encodePlanInt8CodecTextInt64 struct{} type encodePlanInt8CodecTextInt64 struct{}
func (encodePlanInt8CodecTextInt64) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt8CodecTextInt64) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int64) n := value.(int64)
return append(buf, strconv.FormatInt(int64(n), 10)...), nil return append(buf, strconv.FormatInt(int64(n), 10)...), nil
} }
type encodePlanInt8CodecBinaryInt64Valuer struct{} type encodePlanInt8CodecBinaryInt64Valuer struct{}
func (encodePlanInt8CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt8CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -1317,7 +1317,7 @@ func (encodePlanInt8CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte
type encodePlanInt8CodecTextInt64Valuer struct{} type encodePlanInt8CodecTextInt64Valuer struct{}
func (encodePlanInt8CodecTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt8CodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -1337,7 +1337,7 @@ func (encodePlanInt8CodecTextInt64Valuer) Encode(value interface{}, buf []byte)
return append(buf, strconv.FormatInt(n.Int64, 10)...), nil return append(buf, strconv.FormatInt(n.Int64, 10)...), nil
} }
func (Int8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Int8Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -1410,7 +1410,7 @@ func (c Int8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return n, nil return n, nil
} }
func (c Int8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Int8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -1425,7 +1425,7 @@ func (c Int8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanBinaryInt8ToInt8 struct{} type scanPlanBinaryInt8ToInt8 struct{}
func (scanPlanBinaryInt8ToInt8) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToInt8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1453,7 +1453,7 @@ func (scanPlanBinaryInt8ToInt8) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToUint8 struct{} type scanPlanBinaryInt8ToUint8 struct{}
func (scanPlanBinaryInt8ToUint8) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToUint8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1483,7 +1483,7 @@ func (scanPlanBinaryInt8ToUint8) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToInt16 struct{} type scanPlanBinaryInt8ToInt16 struct{}
func (scanPlanBinaryInt8ToInt16) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToInt16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1511,7 +1511,7 @@ func (scanPlanBinaryInt8ToInt16) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToUint16 struct{} type scanPlanBinaryInt8ToUint16 struct{}
func (scanPlanBinaryInt8ToUint16) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToUint16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1541,7 +1541,7 @@ func (scanPlanBinaryInt8ToUint16) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToInt32 struct{} type scanPlanBinaryInt8ToInt32 struct{}
func (scanPlanBinaryInt8ToInt32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToInt32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1569,7 +1569,7 @@ func (scanPlanBinaryInt8ToInt32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToUint32 struct{} type scanPlanBinaryInt8ToUint32 struct{}
func (scanPlanBinaryInt8ToUint32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToUint32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1599,7 +1599,7 @@ func (scanPlanBinaryInt8ToUint32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToInt64 struct{} type scanPlanBinaryInt8ToInt64 struct{}
func (scanPlanBinaryInt8ToInt64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToInt64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1620,7 +1620,7 @@ func (scanPlanBinaryInt8ToInt64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToUint64 struct{} type scanPlanBinaryInt8ToUint64 struct{}
func (scanPlanBinaryInt8ToUint64) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToUint64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1646,7 +1646,7 @@ func (scanPlanBinaryInt8ToUint64) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToInt struct{} type scanPlanBinaryInt8ToInt struct{}
func (scanPlanBinaryInt8ToInt) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToInt) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1674,7 +1674,7 @@ func (scanPlanBinaryInt8ToInt) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToUint struct{} type scanPlanBinaryInt8ToUint struct{}
func (scanPlanBinaryInt8ToUint) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToUint) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1704,7 +1704,7 @@ func (scanPlanBinaryInt8ToUint) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryInt8ToInt64Scanner struct{} type scanPlanBinaryInt8ToInt64Scanner struct{}
func (scanPlanBinaryInt8ToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner) s, ok := (dst).(Int64Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -1725,7 +1725,7 @@ func (scanPlanBinaryInt8ToInt64Scanner) Scan(src []byte, dst interface{}) error
type scanPlanBinaryInt8ToTextScanner struct{} type scanPlanBinaryInt8ToTextScanner struct{}
func (scanPlanBinaryInt8ToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt8ToTextScanner) Scan(src []byte, dst any) error {
s, ok := (dst).(TextScanner) s, ok := (dst).(TextScanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -1746,7 +1746,7 @@ func (scanPlanBinaryInt8ToTextScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInt8 struct{} type scanPlanTextAnyToInt8 struct{}
func (scanPlanTextAnyToInt8) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1767,7 +1767,7 @@ func (scanPlanTextAnyToInt8) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToUint8 struct{} type scanPlanTextAnyToUint8 struct{}
func (scanPlanTextAnyToUint8) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint8) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1788,7 +1788,7 @@ func (scanPlanTextAnyToUint8) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInt16 struct{} type scanPlanTextAnyToInt16 struct{}
func (scanPlanTextAnyToInt16) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1809,7 +1809,7 @@ func (scanPlanTextAnyToInt16) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToUint16 struct{} type scanPlanTextAnyToUint16 struct{}
func (scanPlanTextAnyToUint16) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint16) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1830,7 +1830,7 @@ func (scanPlanTextAnyToUint16) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInt32 struct{} type scanPlanTextAnyToInt32 struct{}
func (scanPlanTextAnyToInt32) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1851,7 +1851,7 @@ func (scanPlanTextAnyToInt32) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToUint32 struct{} type scanPlanTextAnyToUint32 struct{}
func (scanPlanTextAnyToUint32) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1872,7 +1872,7 @@ func (scanPlanTextAnyToUint32) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInt64 struct{} type scanPlanTextAnyToInt64 struct{}
func (scanPlanTextAnyToInt64) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1893,7 +1893,7 @@ func (scanPlanTextAnyToInt64) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToUint64 struct{} type scanPlanTextAnyToUint64 struct{}
func (scanPlanTextAnyToUint64) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint64) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1914,7 +1914,7 @@ func (scanPlanTextAnyToUint64) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInt struct{} type scanPlanTextAnyToInt struct{}
func (scanPlanTextAnyToInt) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1935,7 +1935,7 @@ func (scanPlanTextAnyToInt) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToUint struct{} type scanPlanTextAnyToUint struct{}
func (scanPlanTextAnyToUint) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -1956,7 +1956,7 @@ func (scanPlanTextAnyToUint) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToInt64Scanner struct{} type scanPlanTextAnyToInt64Scanner struct{}
func (scanPlanTextAnyToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner) s, ok := (dst).(Int64Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
+17 -17
View File
@@ -49,7 +49,7 @@ func (n Int<%= pg_byte_size %>) Int64Value() (Int8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int<%= pg_byte_size %>) Scan(src interface{}) error { func (dst *Int<%= pg_byte_size %>) Scan(src any) error {
if src == nil { if src == nil {
*dst = Int<%= pg_byte_size %>{} *dst = Int<%= pg_byte_size %>{}
return nil return nil
@@ -128,7 +128,7 @@ func (Int<%= pg_byte_size %>Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Int<%= pg_byte_size %>Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Int<%= pg_byte_size %>Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -151,21 +151,21 @@ func (Int<%= pg_byte_size %>Codec) PlanEncode(m *Map, oid uint32, format int16,
type encodePlanInt<%= pg_byte_size %>CodecBinaryInt<%= pg_bit_size %> struct{} type encodePlanInt<%= pg_byte_size %>CodecBinaryInt<%= pg_bit_size %> struct{}
func (encodePlanInt<%= pg_byte_size %>CodecBinaryInt<%= pg_bit_size %>) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt<%= pg_byte_size %>CodecBinaryInt<%= pg_bit_size %>) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int<%= pg_bit_size %>) n := value.(int<%= pg_bit_size %>)
return pgio.AppendInt<%= pg_bit_size %>(buf, int<%= pg_bit_size %>(n)), nil return pgio.AppendInt<%= pg_bit_size %>(buf, int<%= pg_bit_size %>(n)), nil
} }
type encodePlanInt<%= pg_byte_size %>CodecTextInt<%= pg_bit_size %> struct{} type encodePlanInt<%= pg_byte_size %>CodecTextInt<%= pg_bit_size %> struct{}
func (encodePlanInt<%= pg_byte_size %>CodecTextInt<%= pg_bit_size %>) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt<%= pg_byte_size %>CodecTextInt<%= pg_bit_size %>) Encode(value any, buf []byte) (newBuf []byte, err error) {
n := value.(int<%= pg_bit_size %>) n := value.(int<%= pg_bit_size %>)
return append(buf, strconv.FormatInt(int64(n), 10)...), nil return append(buf, strconv.FormatInt(int64(n), 10)...), nil
} }
type encodePlanInt<%= pg_byte_size %>CodecBinaryInt64Valuer struct{} type encodePlanInt<%= pg_byte_size %>CodecBinaryInt64Valuer struct{}
func (encodePlanInt<%= pg_byte_size %>CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt<%= pg_byte_size %>CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -187,7 +187,7 @@ func (encodePlanInt<%= pg_byte_size %>CodecBinaryInt64Valuer) Encode(value inter
type encodePlanInt<%= pg_byte_size %>CodecTextInt64Valuer struct{} type encodePlanInt<%= pg_byte_size %>CodecTextInt64Valuer struct{}
func (encodePlanInt<%= pg_byte_size %>CodecTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanInt<%= pg_byte_size %>CodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -207,7 +207,7 @@ func (encodePlanInt<%= pg_byte_size %>CodecTextInt64Valuer) Encode(value interfa
return append(buf, strconv.FormatInt(n.Int64, 10)...), nil return append(buf, strconv.FormatInt(n.Int64, 10)...), nil
} }
func (Int<%= pg_byte_size %>Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Int<%= pg_byte_size %>Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -280,7 +280,7 @@ func (c Int<%= pg_byte_size %>Codec) DecodeDatabaseSQLValue(m *Map, oid uint32,
return n, nil return n, nil
} }
func (c Int<%= pg_byte_size %>Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Int<%= pg_byte_size %>Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -297,7 +297,7 @@ func (c Int<%= pg_byte_size %>Codec) DecodeValue(m *Map, oid uint32, format int1
<% [8, 16, 32, 64].each do |dst_bit_size| %> <% [8, 16, 32, 64].each do |dst_bit_size| %>
type scanPlanBinaryInt<%= pg_byte_size %>ToInt<%= dst_bit_size %> struct{} type scanPlanBinaryInt<%= pg_byte_size %>ToInt<%= dst_bit_size %> struct{}
func (scanPlanBinaryInt<%= pg_byte_size %>ToInt<%= dst_bit_size %>) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt<%= pg_byte_size %>ToInt<%= dst_bit_size %>) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -331,7 +331,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToInt<%= dst_bit_size %>) Scan(src []b
type scanPlanBinaryInt<%= pg_byte_size %>ToUint<%= dst_bit_size %> struct{} type scanPlanBinaryInt<%= pg_byte_size %>ToUint<%= dst_bit_size %> struct{}
func (scanPlanBinaryInt<%= pg_byte_size %>ToUint<%= dst_bit_size %>) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt<%= pg_byte_size %>ToUint<%= dst_bit_size %>) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -363,7 +363,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToUint<%= dst_bit_size %>) Scan(src []
<%# PostgreSQL binary format integer to Go machine integers %> <%# PostgreSQL binary format integer to Go machine integers %>
type scanPlanBinaryInt<%= pg_byte_size %>ToInt struct{} type scanPlanBinaryInt<%= pg_byte_size %>ToInt struct{}
func (scanPlanBinaryInt<%= pg_byte_size %>ToInt) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt<%= pg_byte_size %>ToInt) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -395,7 +395,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToInt) Scan(src []byte, dst interface{
type scanPlanBinaryInt<%= pg_byte_size %>ToUint struct{} type scanPlanBinaryInt<%= pg_byte_size %>ToUint struct{}
func (scanPlanBinaryInt<%= pg_byte_size %>ToUint) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt<%= pg_byte_size %>ToUint) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -426,7 +426,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToUint) Scan(src []byte, dst interface
<%# PostgreSQL binary format integer to Go Int64Scanner %> <%# PostgreSQL binary format integer to Go Int64Scanner %>
type scanPlanBinaryInt<%= pg_byte_size %>ToInt64Scanner struct{} type scanPlanBinaryInt<%= pg_byte_size %>ToInt64Scanner struct{}
func (scanPlanBinaryInt<%= pg_byte_size %>ToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt<%= pg_byte_size %>ToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner) s, ok := (dst).(Int64Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -449,7 +449,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToInt64Scanner) Scan(src []byte, dst i
<%# PostgreSQL binary format integer to Go TextScanner %> <%# PostgreSQL binary format integer to Go TextScanner %>
type scanPlanBinaryInt<%= pg_byte_size %>ToTextScanner struct{} type scanPlanBinaryInt<%= pg_byte_size %>ToTextScanner struct{}
func (scanPlanBinaryInt<%= pg_byte_size %>ToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryInt<%= pg_byte_size %>ToTextScanner) Scan(src []byte, dst any) error {
s, ok := (dst).(TextScanner) s, ok := (dst).(TextScanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -480,7 +480,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToTextScanner) Scan(src []byte, dst in
].each do |type_suffix, bit_size| %> ].each do |type_suffix, bit_size| %>
type scanPlanTextAnyToInt<%= type_suffix %> struct{} type scanPlanTextAnyToInt<%= type_suffix %> struct{}
func (scanPlanTextAnyToInt<%= type_suffix %>) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt<%= type_suffix %>) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -501,7 +501,7 @@ func (scanPlanTextAnyToInt<%= type_suffix %>) Scan(src []byte, dst interface{})
type scanPlanTextAnyToUint<%= type_suffix %> struct{} type scanPlanTextAnyToUint<%= type_suffix %> struct{}
func (scanPlanTextAnyToUint<%= type_suffix %>) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint<%= type_suffix %>) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -523,7 +523,7 @@ func (scanPlanTextAnyToUint<%= type_suffix %>) Scan(src []byte, dst interface{})
type scanPlanTextAnyToInt64Scanner struct{} type scanPlanTextAnyToInt64Scanner struct{}
func (scanPlanTextAnyToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToInt64Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Int64Scanner) s, ok := (dst).(Int64Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
+140 -140
View File
@@ -17,8 +17,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_1_rows_1_columns(b *test
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -36,8 +36,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_1_rows_1_columns(b *te
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -55,8 +55,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_1_rows_10_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -74,8 +74,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_1_rows_10_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -93,8 +93,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_10_rows_1_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -112,8 +112,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_10_rows_1_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -131,8 +131,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_100_rows_10_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -150,8 +150,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_100_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -169,8 +169,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_1_rows_1_columns(b *test
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -188,8 +188,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_1_rows_1_columns(b *te
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -207,8 +207,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_1_rows_10_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -226,8 +226,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_1_rows_10_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -245,8 +245,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_10_rows_1_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -264,8 +264,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_10_rows_1_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -283,8 +283,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_100_rows_10_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -302,8 +302,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_100_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -321,8 +321,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_1_rows_1_columns(b *test
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -340,8 +340,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_1_rows_1_columns(b *te
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -359,8 +359,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_1_rows_10_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -378,8 +378,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_1_rows_10_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -397,8 +397,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_10_rows_1_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -416,8 +416,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_10_rows_1_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -435,8 +435,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_100_rows_10_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -454,8 +454,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_100_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -473,8 +473,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_1_rows_1_columns(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -492,8 +492,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_1_rows_1_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -511,8 +511,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_1_rows_10_columns(b *te
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -530,8 +530,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_1_rows_10_columns(b *
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -549,8 +549,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_10_rows_1_columns(b *te
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -568,8 +568,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_10_rows_1_columns(b *
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -587,8 +587,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_100_rows_10_columns(b *
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -606,8 +606,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_100_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -625,8 +625,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_1_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -644,8 +644,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_1_columns
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 1) n`, `select n::int4 + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -663,8 +663,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_10_columns(
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -682,8 +682,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_10_column
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -701,8 +701,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_10_rows_1_columns(
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -720,8 +720,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_10_rows_1_column
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0 from generate_series(1, 10) n`, `select n::int4 + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -739,8 +739,8 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_100_rows_10_column
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -758,8 +758,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_100_rows_10_colu
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`, `select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -777,8 +777,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_1_rows_1_columns(b *t
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 1) n`, `select n::numeric + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -796,8 +796,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_1_rows_1_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 1) n`, `select n::numeric + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -815,8 +815,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_1_rows_10_columns(b *
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -834,8 +834,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_1_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -853,8 +853,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_10_rows_1_columns(b *
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 10) n`, `select n::numeric + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -872,8 +872,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_10_rows_1_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 10) n`, `select n::numeric + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -891,8 +891,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_100_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -910,8 +910,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_100_rows_10_columns
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -929,8 +929,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_1_rows_1_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 1) n`, `select n::numeric + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -948,8 +948,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_1_rows_1_columns(
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 1) n`, `select n::numeric + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -967,8 +967,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_1_rows_10_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -986,8 +986,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_1_rows_10_columns
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1005,8 +1005,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_10_rows_1_columns(b
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 10) n`, `select n::numeric + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1024,8 +1024,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_10_rows_1_columns
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 10) n`, `select n::numeric + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1043,8 +1043,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_100_rows_10_columns
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1062,8 +1062,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_100_rows_10_colum
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1081,8 +1081,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_1_col
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 1) n`, `select n::numeric + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1100,8 +1100,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_1_c
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 1) n`, `select n::numeric + 0 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1119,8 +1119,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_10_co
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1138,8 +1138,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_10_
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1157,8 +1157,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_10_rows_1_co
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 10) n`, `select n::numeric + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1176,8 +1176,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_10_rows_1_
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0 from generate_series(1, 10) n`, `select n::numeric + 0 from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0]}, []any{&v[0]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1195,8 +1195,8 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_100_rows_10_
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1214,8 +1214,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_100_rows_1
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`, `select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1233,8 +1233,8 @@ func BenchmarkQueryTextFormatDecode_PG_Int4Array_With_Go_Int4Array_10(b *testing
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, 10) n`, `select array_agg(n) from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1252,8 +1252,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_Int4Array_With_Go_Int4Array_10(b *testi
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, 10) n`, `select array_agg(n) from generate_series(1, 10) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1271,8 +1271,8 @@ func BenchmarkQueryTextFormatDecode_PG_Int4Array_With_Go_Int4Array_100(b *testin
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, 100) n`, `select array_agg(n) from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1290,8 +1290,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_Int4Array_With_Go_Int4Array_100(b *test
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, 100) n`, `select array_agg(n) from generate_series(1, 100) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1309,8 +1309,8 @@ func BenchmarkQueryTextFormatDecode_PG_Int4Array_With_Go_Int4Array_1000(b *testi
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, 1000) n`, `select array_agg(n) from generate_series(1, 1000) n`,
[]interface{}{pgx.QueryResultFormats{pgx.TextFormatCode}}, []any{pgx.QueryResultFormats{pgx.TextFormatCode}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -1328,8 +1328,8 @@ func BenchmarkQueryBinaryFormatDecode_PG_Int4Array_With_Go_Int4Array_1000(b *tes
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, 1000) n`, `select array_agg(n) from generate_series(1, 1000) n`,
[]interface{}{pgx.QueryResultFormats{pgx.BinaryFormatCode}}, []any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
+4 -4
View File
@@ -25,8 +25,8 @@ func BenchmarkQuery<%= format_name %>FormatDecode_PG_<%= pg_type %>_to_Go_<%= go
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select <% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>n::<%= pg_type %> + <%= col_idx%><% end %> from generate_series(1, <%= rows %>) n`, `select <% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>n::<%= pg_type %> + <%= col_idx%><% end %> from generate_series(1, <%= rows %>) n`,
[]interface{}{pgx.QueryResultFormats{<%= format_code %>}}, []any{pgx.QueryResultFormats{<%= format_code %>}},
[]interface{}{<% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>&v[<%= col_idx%>]<% end %>}, []any{<% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>&v[<%= col_idx%>]<% end %>},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
@@ -50,8 +50,8 @@ func BenchmarkQuery<%= format_name %>FormatDecode_PG_Int4Array_With_Go_Int4Array
_, err := conn.QueryFunc( _, err := conn.QueryFunc(
ctx, ctx,
`select array_agg(n) from generate_series(1, <%= array_size %>) n`, `select array_agg(n) from generate_series(1, <%= array_size %>) n`,
[]interface{}{pgx.QueryResultFormats{<%= format_code %>}}, []any{pgx.QueryResultFormats{<%= format_code %>}},
[]interface{}{&v}, []any{&v},
func(pgx.QueryFuncRow) error { return nil }, func(pgx.QueryFuncRow) error { return nil },
) )
if err != nil { if err != nil {
+8 -8
View File
@@ -43,7 +43,7 @@ func (interval Interval) IntervalValue() (Interval, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (interval *Interval) Scan(src interface{}) error { func (interval *Interval) Scan(src any) error {
if src == nil { if src == nil {
*interval = Interval{} *interval = Interval{}
return nil return nil
@@ -80,7 +80,7 @@ func (IntervalCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (IntervalCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (IntervalCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(IntervalValuer); !ok { if _, ok := value.(IntervalValuer); !ok {
return nil return nil
} }
@@ -97,7 +97,7 @@ func (IntervalCodec) PlanEncode(m *Map, oid uint32, format int16, value interfac
type encodePlanIntervalCodecBinary struct{} type encodePlanIntervalCodecBinary struct{}
func (encodePlanIntervalCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanIntervalCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
interval, err := value.(IntervalValuer).IntervalValue() interval, err := value.(IntervalValuer).IntervalValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -115,7 +115,7 @@ func (encodePlanIntervalCodecBinary) Encode(value interface{}, buf []byte) (newB
type encodePlanIntervalCodecText struct{} type encodePlanIntervalCodecText struct{}
func (encodePlanIntervalCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanIntervalCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
interval, err := value.(IntervalValuer).IntervalValue() interval, err := value.(IntervalValuer).IntervalValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -151,7 +151,7 @@ func (encodePlanIntervalCodecText) Encode(value interface{}, buf []byte) (newBuf
return buf, nil return buf, nil
} }
func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -171,7 +171,7 @@ func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target interface
type scanPlanBinaryIntervalToIntervalScanner struct{} type scanPlanBinaryIntervalToIntervalScanner struct{}
func (scanPlanBinaryIntervalToIntervalScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryIntervalToIntervalScanner) Scan(src []byte, dst any) error {
scanner := (dst).(IntervalScanner) scanner := (dst).(IntervalScanner)
if src == nil { if src == nil {
@@ -191,7 +191,7 @@ func (scanPlanBinaryIntervalToIntervalScanner) Scan(src []byte, dst interface{})
type scanPlanTextAnyToIntervalScanner struct{} type scanPlanTextAnyToIntervalScanner struct{}
func (scanPlanTextAnyToIntervalScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToIntervalScanner) Scan(src []byte, dst any) error {
scanner := (dst).(IntervalScanner) scanner := (dst).(IntervalScanner)
if src == nil { if src == nil {
@@ -278,7 +278,7 @@ func (c IntervalCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16,
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c IntervalCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c IntervalCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+11 -11
View File
@@ -16,7 +16,7 @@ func (JSONCodec) PreferredFormat() int16 {
return TextFormatCode return TextFormatCode
} }
func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch value.(type) { switch value.(type) {
case string: case string:
return encodePlanJSONCodecEitherFormatString{} return encodePlanJSONCodecEitherFormatString{}
@@ -43,7 +43,7 @@ func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{
type encodePlanJSONCodecEitherFormatString struct{} type encodePlanJSONCodecEitherFormatString struct{}
func (encodePlanJSONCodecEitherFormatString) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanJSONCodecEitherFormatString) Encode(value any, buf []byte) (newBuf []byte, err error) {
jsonString := value.(string) jsonString := value.(string)
buf = append(buf, jsonString...) buf = append(buf, jsonString...)
return buf, nil return buf, nil
@@ -51,7 +51,7 @@ func (encodePlanJSONCodecEitherFormatString) Encode(value interface{}, buf []byt
type encodePlanJSONCodecEitherFormatByteSlice struct{} type encodePlanJSONCodecEitherFormatByteSlice struct{}
func (encodePlanJSONCodecEitherFormatByteSlice) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanJSONCodecEitherFormatByteSlice) Encode(value any, buf []byte) (newBuf []byte, err error) {
jsonBytes := value.([]byte) jsonBytes := value.([]byte)
if jsonBytes == nil { if jsonBytes == nil {
return nil, nil return nil, nil
@@ -63,7 +63,7 @@ func (encodePlanJSONCodecEitherFormatByteSlice) Encode(value interface{}, buf []
type encodePlanJSONCodecEitherFormatMarshal struct{} type encodePlanJSONCodecEitherFormatMarshal struct{}
func (encodePlanJSONCodecEitherFormatMarshal) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanJSONCodecEitherFormatMarshal) Encode(value any, buf []byte) (newBuf []byte, err error) {
jsonBytes, err := json.Marshal(value) jsonBytes, err := json.Marshal(value)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -73,7 +73,7 @@ func (encodePlanJSONCodecEitherFormatMarshal) Encode(value interface{}, buf []by
return buf, nil return buf, nil
} }
func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch target.(type) { switch target.(type) {
case *string: case *string:
return scanPlanAnyToString{} return scanPlanAnyToString{}
@@ -89,7 +89,7 @@ func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanAnyToString struct{} type scanPlanAnyToString struct{}
func (scanPlanAnyToString) Scan(src []byte, dst interface{}) error { func (scanPlanAnyToString) Scan(src []byte, dst any) error {
p := dst.(*string) p := dst.(*string)
*p = string(src) *p = string(src)
return nil return nil
@@ -97,7 +97,7 @@ func (scanPlanAnyToString) Scan(src []byte, dst interface{}) error {
type scanPlanJSONToByteSlice struct{} type scanPlanJSONToByteSlice struct{}
func (scanPlanJSONToByteSlice) Scan(src []byte, dst interface{}) error { func (scanPlanJSONToByteSlice) Scan(src []byte, dst any) error {
dstBuf := dst.(*[]byte) dstBuf := dst.(*[]byte)
if src == nil { if src == nil {
*dstBuf = nil *dstBuf = nil
@@ -111,14 +111,14 @@ func (scanPlanJSONToByteSlice) Scan(src []byte, dst interface{}) error {
type scanPlanJSONToBytesScanner struct{} type scanPlanJSONToBytesScanner struct{}
func (scanPlanJSONToBytesScanner) Scan(src []byte, dst interface{}) error { func (scanPlanJSONToBytesScanner) Scan(src []byte, dst any) error {
scanner := (dst).(BytesScanner) scanner := (dst).(BytesScanner)
return scanner.ScanBytes(src) return scanner.ScanBytes(src)
} }
type scanPlanJSONToJSONUnmarshal struct{} type scanPlanJSONToJSONUnmarshal struct{}
func (scanPlanJSONToJSONUnmarshal) Scan(src []byte, dst interface{}) error { func (scanPlanJSONToJSONUnmarshal) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
dstValue := reflect.ValueOf(dst) dstValue := reflect.ValueOf(dst)
if dstValue.Kind() == reflect.Ptr { if dstValue.Kind() == reflect.Ptr {
@@ -144,12 +144,12 @@ func (c JSONCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return dstBuf, nil return dstBuf, nil
} }
func (c JSONCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c JSONCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
var dst interface{} var dst any
err := json.Unmarshal(src, &dst) err := json.Unmarshal(src, &dst)
return dst, err return dst, err
} }
+7 -7
View File
@@ -7,10 +7,10 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqMap(a interface{}) func(interface{}) bool { func isExpectedEqMap(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
aa := a.(map[string]interface{}) aa := a.(map[string]any)
bb := v.(map[string]interface{}) bb := v.(map[string]any)
if (aa == nil) != (bb == nil) { if (aa == nil) != (bb == nil) {
return false return false
@@ -42,8 +42,8 @@ func TestJSONCodec(t *testing.T) {
pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "json", []pgxtest.ValueRoundTripTest{ pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "json", []pgxtest.ValueRoundTripTest{
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))}, {nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
{map[string]interface{}(nil), new(*string), isExpectedEq((*string)(nil))}, {map[string]any(nil), new(*string), isExpectedEq((*string)(nil))},
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte(nil))}, {map[string]any(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))}, {[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{nil, new([]byte), isExpectedEqBytes([]byte(nil))}, {nil, new([]byte), isExpectedEqBytes([]byte(nil))},
}) })
@@ -54,7 +54,7 @@ func TestJSONCodec(t *testing.T) {
{[]byte("42"), new([]byte), isExpectedEqBytes([]byte("42"))}, {[]byte("42"), new([]byte), isExpectedEqBytes([]byte("42"))},
{[]byte(`"hello"`), new([]byte), isExpectedEqBytes([]byte(`"hello"`))}, {[]byte(`"hello"`), new([]byte), isExpectedEqBytes([]byte(`"hello"`))},
{[]byte(`"hello"`), new(string), isExpectedEq(`"hello"`)}, {[]byte(`"hello"`), new(string), isExpectedEq(`"hello"`)},
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})}, {map[string]any{"foo": "bar"}, new(map[string]any), isExpectedEqMap(map[string]any{"foo": "bar"})},
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})}, {jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
}) })
} }
+6 -6
View File
@@ -16,7 +16,7 @@ func (JSONBCodec) PreferredFormat() int16 {
return TextFormatCode return TextFormatCode
} }
func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
plan := JSONCodec{}.PlanEncode(m, oid, TextFormatCode, value) plan := JSONCodec{}.PlanEncode(m, oid, TextFormatCode, value)
@@ -34,12 +34,12 @@ type encodePlanJSONBCodecBinaryWrapper struct {
textPlan EncodePlan textPlan EncodePlan
} }
func (plan *encodePlanJSONBCodecBinaryWrapper) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *encodePlanJSONBCodecBinaryWrapper) Encode(value any, buf []byte) (newBuf []byte, err error) {
buf = append(buf, 1) buf = append(buf, 1)
return plan.textPlan.Encode(value, buf) return plan.textPlan.Encode(value, buf)
} }
func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
plan := JSONCodec{}.PlanScan(m, oid, TextFormatCode, target) plan := JSONCodec{}.PlanScan(m, oid, TextFormatCode, target)
@@ -57,7 +57,7 @@ type scanPlanJSONBCodecBinaryUnwrapper struct {
textPlan ScanPlan textPlan ScanPlan
} }
func (plan *scanPlanJSONBCodecBinaryUnwrapper) Scan(src []byte, dst interface{}) error { func (plan *scanPlanJSONBCodecBinaryUnwrapper) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return plan.textPlan.Scan(src, dst) return plan.textPlan.Scan(src, dst)
} }
@@ -100,7 +100,7 @@ func (c JSONBCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
} }
} }
func (c JSONBCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c JSONBCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -121,7 +121,7 @@ func (c JSONBCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (i
return nil, fmt.Errorf("unknown format code: %v", format) return nil, fmt.Errorf("unknown format code: %v", format)
} }
var dst interface{} var dst any
err := json.Unmarshal(src, &dst) err := json.Unmarshal(src, &dst)
return dst, err return dst, err
} }
+3 -3
View File
@@ -15,8 +15,8 @@ func TestJSONBTranscode(t *testing.T) {
pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "jsonb", []pgxtest.ValueRoundTripTest{ pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "jsonb", []pgxtest.ValueRoundTripTest{
{nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))}, {nil, new(*jsonStruct), isExpectedEq((*jsonStruct)(nil))},
{map[string]interface{}(nil), new(*string), isExpectedEq((*string)(nil))}, {map[string]any(nil), new(*string), isExpectedEq((*string)(nil))},
{map[string]interface{}(nil), new([]byte), isExpectedEqBytes([]byte(nil))}, {map[string]any(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))}, {[]byte(nil), new([]byte), isExpectedEqBytes([]byte(nil))},
{nil, new([]byte), isExpectedEqBytes([]byte(nil))}, {nil, new([]byte), isExpectedEqBytes([]byte(nil))},
}) })
@@ -27,7 +27,7 @@ func TestJSONBTranscode(t *testing.T) {
{[]byte("42"), new([]byte), isExpectedEqBytes([]byte("42"))}, {[]byte("42"), new([]byte), isExpectedEqBytes([]byte("42"))},
{[]byte(`"hello"`), new([]byte), isExpectedEqBytes([]byte(`"hello"`))}, {[]byte(`"hello"`), new([]byte), isExpectedEqBytes([]byte(`"hello"`))},
{[]byte(`"hello"`), new(string), isExpectedEq(`"hello"`)}, {[]byte(`"hello"`), new(string), isExpectedEq(`"hello"`)},
{map[string]interface{}{"foo": "bar"}, new(map[string]interface{}), isExpectedEqMap(map[string]interface{}{"foo": "bar"})}, {map[string]any{"foo": "bar"}, new(map[string]any), isExpectedEqMap(map[string]any{"foo": "bar"})},
{jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})}, {jsonStruct{Name: "Adam", Age: 10}, new(jsonStruct), isExpectedEq(jsonStruct{Name: "Adam", Age: 10})},
}) })
} }
+9 -9
View File
@@ -33,12 +33,12 @@ func (line Line) LineValue() (Line, error) {
return line, nil return line, nil
} }
func (line *Line) Set(src interface{}) error { func (line *Line) Set(src any) error {
return fmt.Errorf("cannot convert %v to Line", src) return fmt.Errorf("cannot convert %v to Line", src)
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (line *Line) Scan(src interface{}) error { func (line *Line) Scan(src any) error {
if src == nil { if src == nil {
*line = Line{} *line = Line{}
return nil return nil
@@ -75,7 +75,7 @@ func (LineCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (LineCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (LineCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(LineValuer); !ok { if _, ok := value.(LineValuer); !ok {
return nil return nil
} }
@@ -92,7 +92,7 @@ func (LineCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanLineCodecBinary struct{} type encodePlanLineCodecBinary struct{}
func (encodePlanLineCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanLineCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
line, err := value.(LineValuer).LineValue() line, err := value.(LineValuer).LineValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -110,7 +110,7 @@ func (encodePlanLineCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanLineCodecText struct{} type encodePlanLineCodecText struct{}
func (encodePlanLineCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanLineCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
line, err := value.(LineValuer).LineValue() line, err := value.(LineValuer).LineValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -128,7 +128,7 @@ func (encodePlanLineCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil return buf, nil
} }
func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -148,7 +148,7 @@ func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryLineToLineScanner struct{} type scanPlanBinaryLineToLineScanner struct{}
func (scanPlanBinaryLineToLineScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryLineToLineScanner) Scan(src []byte, dst any) error {
scanner := (dst).(LineScanner) scanner := (dst).(LineScanner)
if src == nil { if src == nil {
@@ -173,7 +173,7 @@ func (scanPlanBinaryLineToLineScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToLineScanner struct{} type scanPlanTextAnyToLineScanner struct{}
func (scanPlanTextAnyToLineScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToLineScanner) Scan(src []byte, dst any) error {
scanner := (dst).(LineScanner) scanner := (dst).(LineScanner)
if src == nil { if src == nil {
@@ -211,7 +211,7 @@ func (c LineCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c LineCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c LineCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+8 -8
View File
@@ -34,7 +34,7 @@ func (lseg Lseg) LsegValue() (Lseg, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (lseg *Lseg) Scan(src interface{}) error { func (lseg *Lseg) Scan(src any) error {
if src == nil { if src == nil {
*lseg = Lseg{} *lseg = Lseg{}
return nil return nil
@@ -71,7 +71,7 @@ func (LsegCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (LsegCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (LsegCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(LsegValuer); !ok { if _, ok := value.(LsegValuer); !ok {
return nil return nil
} }
@@ -88,7 +88,7 @@ func (LsegCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanLsegCodecBinary struct{} type encodePlanLsegCodecBinary struct{}
func (encodePlanLsegCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanLsegCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
lseg, err := value.(LsegValuer).LsegValue() lseg, err := value.(LsegValuer).LsegValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -107,7 +107,7 @@ func (encodePlanLsegCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanLsegCodecText struct{} type encodePlanLsegCodecText struct{}
func (encodePlanLsegCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanLsegCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
lseg, err := value.(LsegValuer).LsegValue() lseg, err := value.(LsegValuer).LsegValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -126,7 +126,7 @@ func (encodePlanLsegCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil return buf, nil
} }
func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -146,7 +146,7 @@ func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryLsegToLsegScanner struct{} type scanPlanBinaryLsegToLsegScanner struct{}
func (scanPlanBinaryLsegToLsegScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryLsegToLsegScanner) Scan(src []byte, dst any) error {
scanner := (dst).(LsegScanner) scanner := (dst).(LsegScanner)
if src == nil { if src == nil {
@@ -173,7 +173,7 @@ func (scanPlanBinaryLsegToLsegScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToLsegScanner struct{} type scanPlanTextAnyToLsegScanner struct{}
func (scanPlanTextAnyToLsegScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToLsegScanner) Scan(src []byte, dst any) error {
scanner := (dst).(LsegScanner) scanner := (dst).(LsegScanner)
if src == nil { if src == nil {
@@ -224,7 +224,7 @@ func (c LsegCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c LsegCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c LsegCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+9 -9
View File
@@ -15,7 +15,7 @@ func (MacaddrCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (MacaddrCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (MacaddrCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -39,7 +39,7 @@ func (MacaddrCodec) PlanEncode(m *Map, oid uint32, format int16, value interface
type encodePlanMacaddrCodecBinaryHardwareAddr struct{} type encodePlanMacaddrCodecBinaryHardwareAddr struct{}
func (encodePlanMacaddrCodecBinaryHardwareAddr) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanMacaddrCodecBinaryHardwareAddr) Encode(value any, buf []byte) (newBuf []byte, err error) {
addr := value.(net.HardwareAddr) addr := value.(net.HardwareAddr)
if addr == nil { if addr == nil {
return nil, nil return nil, nil
@@ -50,7 +50,7 @@ func (encodePlanMacaddrCodecBinaryHardwareAddr) Encode(value interface{}, buf []
type encodePlanMacAddrCodecTextValuer struct{} type encodePlanMacAddrCodecTextValuer struct{}
func (encodePlanMacAddrCodecTextValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanMacAddrCodecTextValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
t, err := value.(TextValuer).TextValue() t, err := value.(TextValuer).TextValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -69,7 +69,7 @@ func (encodePlanMacAddrCodecTextValuer) Encode(value interface{}, buf []byte) (n
type encodePlanMacaddrCodecTextHardwareAddr struct{} type encodePlanMacaddrCodecTextHardwareAddr struct{}
func (encodePlanMacaddrCodecTextHardwareAddr) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanMacaddrCodecTextHardwareAddr) Encode(value any, buf []byte) (newBuf []byte, err error) {
addr := value.(net.HardwareAddr) addr := value.(net.HardwareAddr)
if addr == nil { if addr == nil {
return nil, nil return nil, nil
@@ -78,7 +78,7 @@ func (encodePlanMacaddrCodecTextHardwareAddr) Encode(value interface{}, buf []by
return append(buf, addr.String()...), nil return append(buf, addr.String()...), nil
} }
func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -101,7 +101,7 @@ func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target interface{
type scanPlanBinaryMacaddrToHardwareAddr struct{} type scanPlanBinaryMacaddrToHardwareAddr struct{}
func (scanPlanBinaryMacaddrToHardwareAddr) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryMacaddrToHardwareAddr) Scan(src []byte, dst any) error {
dstBuf := dst.(*net.HardwareAddr) dstBuf := dst.(*net.HardwareAddr)
if src == nil { if src == nil {
*dstBuf = nil *dstBuf = nil
@@ -115,7 +115,7 @@ func (scanPlanBinaryMacaddrToHardwareAddr) Scan(src []byte, dst interface{}) err
type scanPlanBinaryMacaddrToTextScanner struct{} type scanPlanBinaryMacaddrToTextScanner struct{}
func (scanPlanBinaryMacaddrToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryMacaddrToTextScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TextScanner) scanner := (dst).(TextScanner)
if src == nil { if src == nil {
return scanner.ScanText(Text{}) return scanner.ScanText(Text{})
@@ -126,7 +126,7 @@ func (scanPlanBinaryMacaddrToTextScanner) Scan(src []byte, dst interface{}) erro
type scanPlanTextMacaddrToHardwareAddr struct{} type scanPlanTextMacaddrToHardwareAddr struct{}
func (scanPlanTextMacaddrToHardwareAddr) Scan(src []byte, dst interface{}) error { func (scanPlanTextMacaddrToHardwareAddr) Scan(src []byte, dst any) error {
p := dst.(*net.HardwareAddr) p := dst.(*net.HardwareAddr)
if src == nil { if src == nil {
@@ -148,7 +148,7 @@ func (c MacaddrCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, s
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c MacaddrCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c MacaddrCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqHardwareAddr(a interface{}) func(interface{}) bool { func isExpectedEqHardwareAddr(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
aa := a.(net.HardwareAddr) aa := a.(net.HardwareAddr)
vv := v.(net.HardwareAddr) vv := v.(net.HardwareAddr)
+15 -15
View File
@@ -201,7 +201,7 @@ func nbaseDigitsToInt64(src []byte) (accum int64, bytesRead, digitsRead int) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (n *Numeric) Scan(src interface{}) error { func (n *Numeric) Scan(src any) error {
if src == nil { if src == nil {
*n = Numeric{} *n = Numeric{}
return nil return nil
@@ -281,7 +281,7 @@ func (NumericCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (NumericCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (NumericCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -308,7 +308,7 @@ func (NumericCodec) PlanEncode(m *Map, oid uint32, format int16, value interface
type encodePlanNumericCodecBinaryNumericValuer struct{} type encodePlanNumericCodecBinaryNumericValuer struct{}
func (encodePlanNumericCodecBinaryNumericValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanNumericCodecBinaryNumericValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(NumericValuer).NumericValue() n, err := value.(NumericValuer).NumericValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -319,7 +319,7 @@ func (encodePlanNumericCodecBinaryNumericValuer) Encode(value interface{}, buf [
type encodePlanNumericCodecBinaryFloat64Valuer struct{} type encodePlanNumericCodecBinaryFloat64Valuer struct{}
func (encodePlanNumericCodecBinaryFloat64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanNumericCodecBinaryFloat64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Float64Valuer).Float64Value() n, err := value.(Float64Valuer).Float64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -346,7 +346,7 @@ func (encodePlanNumericCodecBinaryFloat64Valuer) Encode(value interface{}, buf [
type encodePlanNumericCodecBinaryInt64Valuer struct{} type encodePlanNumericCodecBinaryInt64Valuer struct{}
func (encodePlanNumericCodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanNumericCodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -460,7 +460,7 @@ func encodeNumericBinary(n Numeric, buf []byte) (newBuf []byte, err error) {
type encodePlanNumericCodecTextNumericValuer struct{} type encodePlanNumericCodecTextNumericValuer struct{}
func (encodePlanNumericCodecTextNumericValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanNumericCodecTextNumericValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(NumericValuer).NumericValue() n, err := value.(NumericValuer).NumericValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -471,7 +471,7 @@ func (encodePlanNumericCodecTextNumericValuer) Encode(value interface{}, buf []b
type encodePlanNumericCodecTextFloat64Valuer struct{} type encodePlanNumericCodecTextFloat64Valuer struct{}
func (encodePlanNumericCodecTextFloat64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanNumericCodecTextFloat64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Float64Valuer).Float64Value() n, err := value.(Float64Valuer).Float64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -495,7 +495,7 @@ func (encodePlanNumericCodecTextFloat64Valuer) Encode(value interface{}, buf []b
type encodePlanNumericCodecTextInt64Valuer struct{} type encodePlanNumericCodecTextInt64Valuer struct{}
func (encodePlanNumericCodecTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanNumericCodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
n, err := value.(Int64Valuer).Int64Value() n, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -530,7 +530,7 @@ func encodeNumericText(n Numeric, buf []byte) (newBuf []byte, err error) {
return buf, nil return buf, nil
} }
func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -560,7 +560,7 @@ func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target interface{
type scanPlanBinaryNumericToNumericScanner struct{} type scanPlanBinaryNumericToNumericScanner struct{}
func (scanPlanBinaryNumericToNumericScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryNumericToNumericScanner) Scan(src []byte, dst any) error {
scanner := (dst).(NumericScanner) scanner := (dst).(NumericScanner)
if src == nil { if src == nil {
@@ -666,7 +666,7 @@ func (scanPlanBinaryNumericToNumericScanner) Scan(src []byte, dst interface{}) e
type scanPlanBinaryNumericToFloat64Scanner struct{} type scanPlanBinaryNumericToFloat64Scanner struct{}
func (scanPlanBinaryNumericToFloat64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryNumericToFloat64Scanner) Scan(src []byte, dst any) error {
scanner := (dst).(Float64Scanner) scanner := (dst).(Float64Scanner)
if src == nil { if src == nil {
@@ -690,7 +690,7 @@ func (scanPlanBinaryNumericToFloat64Scanner) Scan(src []byte, dst interface{}) e
type scanPlanBinaryNumericToInt64Scanner struct{} type scanPlanBinaryNumericToInt64Scanner struct{}
func (scanPlanBinaryNumericToInt64Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryNumericToInt64Scanner) Scan(src []byte, dst any) error {
scanner := (dst).(Int64Scanner) scanner := (dst).(Int64Scanner)
if src == nil { if src == nil {
@@ -718,7 +718,7 @@ func (scanPlanBinaryNumericToInt64Scanner) Scan(src []byte, dst interface{}) err
type scanPlanBinaryNumericToTextScanner struct{} type scanPlanBinaryNumericToTextScanner struct{}
func (scanPlanBinaryNumericToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryNumericToTextScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TextScanner) scanner := (dst).(TextScanner)
if src == nil { if src == nil {
@@ -742,7 +742,7 @@ func (scanPlanBinaryNumericToTextScanner) Scan(src []byte, dst interface{}) erro
type scanPlanTextAnyToNumericScanner struct{} type scanPlanTextAnyToNumericScanner struct{}
func (scanPlanTextAnyToNumericScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToNumericScanner) Scan(src []byte, dst any) error {
scanner := (dst).(NumericScanner) scanner := (dst).(NumericScanner)
if src == nil { if src == nil {
@@ -787,7 +787,7 @@ func (c NumericCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, s
return string(buf), nil return string(buf), nil
} }
func (c NumericCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c NumericCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+4 -4
View File
@@ -24,8 +24,8 @@ func mustParseBigInt(t *testing.T, src string) *big.Int {
return i return i
} }
func isExpectedEqNumeric(a interface{}) func(interface{}) bool { func isExpectedEqNumeric(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
aa := a.(pgtype.Numeric) aa := a.(pgtype.Numeric)
vv := v.(pgtype.Numeric) vv := v.(pgtype.Numeric)
@@ -101,8 +101,8 @@ func TestNumericCodec(t *testing.T) {
{pgtype.Numeric{NaN: true, Valid: true}, new(pgtype.Numeric), isExpectedEqNumeric(pgtype.Numeric{NaN: true, Valid: true})}, {pgtype.Numeric{NaN: true, Valid: true}, new(pgtype.Numeric), isExpectedEqNumeric(pgtype.Numeric{NaN: true, Valid: true})},
{longestNumeric, new(pgtype.Numeric), isExpectedEqNumeric(longestNumeric)}, {longestNumeric, new(pgtype.Numeric), isExpectedEqNumeric(longestNumeric)},
{mustParseNumeric(t, "1"), new(int64), isExpectedEq(int64(1))}, {mustParseNumeric(t, "1"), new(int64), isExpectedEq(int64(1))},
{math.NaN(), new(float64), func(a interface{}) bool { return math.IsNaN(a.(float64)) }}, {math.NaN(), new(float64), func(a any) bool { return math.IsNaN(a.(float64)) }},
{float32(math.NaN()), new(float32), func(a interface{}) bool { return math.IsNaN(float64(a.(float32))) }}, {float32(math.NaN()), new(float32), func(a any) bool { return math.IsNaN(float64(a.(float32))) }},
{int64(-1), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, "-1"))}, {int64(-1), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, "-1"))},
{int64(0), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, "0"))}, {int64(0), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, "0"))},
{int64(1), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, "1"))}, {int64(1), new(pgtype.Numeric), isExpectedEqNumeric(mustParseNumeric(t, "1"))},
+8 -8
View File
@@ -35,7 +35,7 @@ func (path Path) PathValue() (Path, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (path *Path) Scan(src interface{}) error { func (path *Path) Scan(src any) error {
if src == nil { if src == nil {
*path = Path{} *path = Path{}
return nil return nil
@@ -73,7 +73,7 @@ func (PathCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (PathCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (PathCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(PathValuer); !ok { if _, ok := value.(PathValuer); !ok {
return nil return nil
} }
@@ -90,7 +90,7 @@ func (PathCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanPathCodecBinary struct{} type encodePlanPathCodecBinary struct{}
func (encodePlanPathCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanPathCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
path, err := value.(PathValuer).PathValue() path, err := value.(PathValuer).PathValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -118,7 +118,7 @@ func (encodePlanPathCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanPathCodecText struct{} type encodePlanPathCodecText struct{}
func (encodePlanPathCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanPathCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
path, err := value.(PathValuer).PathValue() path, err := value.(PathValuer).PathValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -153,7 +153,7 @@ func (encodePlanPathCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return buf, nil return buf, nil
} }
func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -173,7 +173,7 @@ func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryPathToPathScanner struct{} type scanPlanBinaryPathToPathScanner struct{}
func (scanPlanBinaryPathToPathScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryPathToPathScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PathScanner) scanner := (dst).(PathScanner)
if src == nil { if src == nil {
@@ -211,7 +211,7 @@ func (scanPlanBinaryPathToPathScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToPathScanner struct{} type scanPlanTextAnyToPathScanner struct{}
func (scanPlanTextAnyToPathScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToPathScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PathScanner) scanner := (dst).(PathScanner)
if src == nil { if src == nil {
@@ -258,7 +258,7 @@ func (c PathCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c PathCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c PathCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqPath(a interface{}) func(interface{}) bool { func isExpectedEqPath(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
ap := a.(pgtype.Path) ap := a.(pgtype.Path)
vp := v.(pgtype.Path) vp := v.(pgtype.Path)
+93 -93
View File
@@ -142,21 +142,21 @@ type Codec interface {
// PlanEncode returns an EncodePlan for encoding value into PostgreSQL format for oid and format. If no plan can be // PlanEncode returns an EncodePlan for encoding value into PostgreSQL format for oid and format. If no plan can be
// found then nil is returned. // found then nil is returned.
PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
// PlanScan returns a ScanPlan for scanning a PostgreSQL value into a destination with the same type as target. If // PlanScan returns a ScanPlan for scanning a PostgreSQL value into a destination with the same type as target. If
// no plan can be found then nil is returned. // no plan can be found then nil is returned.
PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
// DecodeDatabaseSQLValue returns src decoded into a value compatible with the sql.Scanner interface. // DecodeDatabaseSQLValue returns src decoded into a value compatible with the sql.Scanner interface.
DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
// DecodeValue returns src decoded into its default format. // DecodeValue returns src decoded into its default format.
DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)
} }
type nullAssignmentError struct { type nullAssignmentError struct {
dst interface{} dst any
} }
func (e *nullAssignmentError) Error() string { func (e *nullAssignmentError) Error() string {
@@ -316,7 +316,7 @@ func NewMap() *Map {
m.RegisterType(&Type{Name: "_varchar", OID: VarcharArrayOID, Codec: &ArrayCodec{ElementType: m.oidToType[VarcharOID]}}) m.RegisterType(&Type{Name: "_varchar", OID: VarcharArrayOID, Codec: &ArrayCodec{ElementType: m.oidToType[VarcharOID]}})
m.RegisterType(&Type{Name: "_xid", OID: XIDArrayOID, Codec: &ArrayCodec{ElementType: m.oidToType[XIDOID]}}) m.RegisterType(&Type{Name: "_xid", OID: XIDArrayOID, Codec: &ArrayCodec{ElementType: m.oidToType[XIDOID]}})
registerDefaultPgTypeVariants := func(name, arrayName string, value interface{}) { registerDefaultPgTypeVariants := func(name, arrayName string, value any) {
// T // T
m.RegisterDefaultPgType(value, name) m.RegisterDefaultPgType(value, name)
@@ -416,7 +416,7 @@ func (m *Map) RegisterType(t *Type) {
// RegisterDefaultPgType registers a mapping of a Go type to a PostgreSQL type name. Typically the data type to be // RegisterDefaultPgType registers a mapping of a Go type to a PostgreSQL type name. Typically the data type to be
// encoded or decoded is determined by the PostgreSQL OID. But if the OID of a value to be encoded or decoded is // encoded or decoded is determined by the PostgreSQL OID. But if the OID of a value to be encoded or decoded is
// unknown, this additional mapping will be used by TypeForValue to determine a suitable data type. // unknown, this additional mapping will be used by TypeForValue to determine a suitable data type.
func (m *Map) RegisterDefaultPgType(value interface{}, name string) { func (m *Map) RegisterDefaultPgType(value any, name string) {
m.reflectTypeToName[reflect.TypeOf(value)] = name m.reflectTypeToName[reflect.TypeOf(value)] = name
// Invalidated by type registration // Invalidated by type registration
@@ -448,7 +448,7 @@ func (m *Map) buildReflectTypeToType() {
// TypeForValue finds a data type suitable for v. Use RegisterType to register types that can encode and decode // TypeForValue finds a data type suitable for v. Use RegisterType to register types that can encode and decode
// themselves. Use RegisterDefaultPgType to register that can be handled by a registered data type. // themselves. Use RegisterDefaultPgType to register that can be handled by a registered data type.
func (m *Map) TypeForValue(v interface{}) (*Type, bool) { func (m *Map) TypeForValue(v any) (*Type, bool) {
if m.reflectTypeToType == nil { if m.reflectTypeToType == nil {
m.buildReflectTypeToType() m.buildReflectTypeToType()
} }
@@ -472,13 +472,13 @@ type EncodePlan interface {
// Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return // Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return
// (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data // (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data
// written. // written.
Encode(value interface{}, buf []byte) (newBuf []byte, err error) Encode(value any, buf []byte) (newBuf []byte, err error)
} }
// ScanPlan is a precompiled plan to scan into a type of destination. // ScanPlan is a precompiled plan to scan into a type of destination.
type ScanPlan interface { type ScanPlan interface {
// Scan scans src into target. // Scan scans src into target.
Scan(src []byte, target interface{}) error Scan(src []byte, target any) error
} }
type scanPlanCodecSQLScanner struct { type scanPlanCodecSQLScanner struct {
@@ -488,7 +488,7 @@ type scanPlanCodecSQLScanner struct {
formatCode int16 formatCode int16
} }
func (plan *scanPlanCodecSQLScanner) Scan(src []byte, dst interface{}) error { func (plan *scanPlanCodecSQLScanner) Scan(src []byte, dst any) error {
value, err := plan.c.DecodeDatabaseSQLValue(plan.m, plan.oid, plan.formatCode, src) value, err := plan.c.DecodeDatabaseSQLValue(plan.m, plan.oid, plan.formatCode, src)
if err != nil { if err != nil {
return err return err
@@ -502,7 +502,7 @@ type scanPlanSQLScanner struct {
formatCode int16 formatCode int16
} }
func (plan *scanPlanSQLScanner) Scan(src []byte, dst interface{}) error { func (plan *scanPlanSQLScanner) Scan(src []byte, dst any) error {
scanner := dst.(sql.Scanner) scanner := dst.(sql.Scanner)
if src == nil { if src == nil {
// This is necessary because interface value []byte:nil does not equal nil:nil for the binary format path and the // This is necessary because interface value []byte:nil does not equal nil:nil for the binary format path and the
@@ -517,7 +517,7 @@ func (plan *scanPlanSQLScanner) Scan(src []byte, dst interface{}) error {
type scanPlanString struct{} type scanPlanString struct{}
func (scanPlanString) Scan(src []byte, dst interface{}) error { func (scanPlanString) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -529,7 +529,7 @@ func (scanPlanString) Scan(src []byte, dst interface{}) error {
type scanPlanAnyTextToBytes struct{} type scanPlanAnyTextToBytes struct{}
func (scanPlanAnyTextToBytes) Scan(src []byte, dst interface{}) error { func (scanPlanAnyTextToBytes) Scan(src []byte, dst any) error {
dstBuf := dst.(*[]byte) dstBuf := dst.(*[]byte)
if src == nil { if src == nil {
*dstBuf = nil *dstBuf = nil
@@ -546,7 +546,7 @@ type scanPlanFail struct {
formatCode int16 formatCode int16
} }
func (plan *scanPlanFail) Scan(src []byte, dst interface{}) error { func (plan *scanPlanFail) Scan(src []byte, dst any) error {
var format string var format string
switch plan.formatCode { switch plan.formatCode {
case TextFormatCode: case TextFormatCode:
@@ -564,7 +564,7 @@ func (plan *scanPlanFail) Scan(src []byte, dst interface{}) error {
// that will convert the target passed to Scan and then call the next plan. nextTarget is target as it will be converted // that will convert the target passed to Scan and then call the next plan. nextTarget is target as it will be converted
// by plan. It must be used to find another suitable ScanPlan. When it is found SetNext must be called on plan for it // by plan. It must be used to find another suitable ScanPlan. When it is found SetNext must be called on plan for it
// to be usabled. ok indicates if a suitable wrapper was found. // to be usabled. ok indicates if a suitable wrapper was found.
type TryWrapScanPlanFunc func(target interface{}) (plan WrappedScanPlanNextSetter, nextTarget interface{}, ok bool) type TryWrapScanPlanFunc func(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool)
type pointerPointerScanPlan struct { type pointerPointerScanPlan struct {
dstType reflect.Type dstType reflect.Type
@@ -573,7 +573,7 @@ type pointerPointerScanPlan struct {
func (plan *pointerPointerScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *pointerPointerScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *pointerPointerScanPlan) Scan(src []byte, dst interface{}) error { func (plan *pointerPointerScanPlan) Scan(src []byte, dst any) error {
el := reflect.ValueOf(dst).Elem() el := reflect.ValueOf(dst).Elem()
if src == nil { if src == nil {
el.Set(reflect.Zero(el.Type())) el.Set(reflect.Zero(el.Type()))
@@ -586,7 +586,7 @@ func (plan *pointerPointerScanPlan) Scan(src []byte, dst interface{}) error {
// TryPointerPointerScanPlan handles a pointer to a pointer by setting the target to nil for SQL NULL and allocating and // TryPointerPointerScanPlan handles a pointer to a pointer by setting the target to nil for SQL NULL and allocating and
// scanning for non-NULL. // scanning for non-NULL.
func TryPointerPointerScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextTarget interface{}, ok bool) { func TryPointerPointerScanPlan(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool) {
if dstValue := reflect.ValueOf(target); dstValue.Kind() == reflect.Ptr { if dstValue := reflect.ValueOf(target); dstValue.Kind() == reflect.Ptr {
elemValue := dstValue.Elem() elemValue := dstValue.Elem()
if elemValue.Kind() == reflect.Ptr { if elemValue.Kind() == reflect.Ptr {
@@ -627,13 +627,13 @@ type underlyingTypeScanPlan struct {
func (plan *underlyingTypeScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *underlyingTypeScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *underlyingTypeScanPlan) Scan(src []byte, dst interface{}) error { func (plan *underlyingTypeScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, reflect.ValueOf(dst).Convert(plan.nextDstType).Interface()) return plan.next.Scan(src, reflect.ValueOf(dst).Convert(plan.nextDstType).Interface())
} }
// TryFindUnderlyingTypeScanPlan tries to convert to a Go builtin type. e.g. If value was of type MyString and // TryFindUnderlyingTypeScanPlan tries to convert to a Go builtin type. e.g. If value was of type MyString and
// MyString was defined as a string then a wrapper plan would be returned that converts MyString to string. // MyString was defined as a string then a wrapper plan would be returned that converts MyString to string.
func TryFindUnderlyingTypeScanPlan(dst interface{}) (plan WrappedScanPlanNextSetter, nextDst interface{}, ok bool) { func TryFindUnderlyingTypeScanPlan(dst any) (plan WrappedScanPlanNextSetter, nextDst any, ok bool) {
if _, ok := dst.(SkipUnderlyingTypePlanner); ok { if _, ok := dst.(SkipUnderlyingTypePlanner); ok {
return nil, nil, false return nil, nil, false
} }
@@ -667,7 +667,7 @@ type WrappedScanPlanNextSetter interface {
// TryWrapBuiltinTypeScanPlan tries to wrap a builtin type with a wrapper that provides additional methods. e.g. If // TryWrapBuiltinTypeScanPlan tries to wrap a builtin type with a wrapper that provides additional methods. e.g. If
// value was of type int32 then a wrapper plan would be returned that converts target to a value that implements // value was of type int32 then a wrapper plan would be returned that converts target to a value that implements
// Int64Scanner. // Int64Scanner.
func TryWrapBuiltinTypeScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextDst interface{}, ok bool) { func TryWrapBuiltinTypeScanPlan(target any) (plan WrappedScanPlanNextSetter, nextDst any, ok bool) {
switch target := target.(type) { switch target := target.(type) {
case *int8: case *int8:
return &wrapInt8ScanPlan{}, (*int8Wrapper)(target), true return &wrapInt8ScanPlan{}, (*int8Wrapper)(target), true
@@ -722,7 +722,7 @@ type wrapInt8ScanPlan struct {
func (plan *wrapInt8ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapInt8ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapInt8ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapInt8ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*int8Wrapper)(dst.(*int8))) return plan.next.Scan(src, (*int8Wrapper)(dst.(*int8)))
} }
@@ -732,7 +732,7 @@ type wrapInt16ScanPlan struct {
func (plan *wrapInt16ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapInt16ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapInt16ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapInt16ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*int16Wrapper)(dst.(*int16))) return plan.next.Scan(src, (*int16Wrapper)(dst.(*int16)))
} }
@@ -742,7 +742,7 @@ type wrapInt32ScanPlan struct {
func (plan *wrapInt32ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapInt32ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapInt32ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapInt32ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*int32Wrapper)(dst.(*int32))) return plan.next.Scan(src, (*int32Wrapper)(dst.(*int32)))
} }
@@ -752,7 +752,7 @@ type wrapInt64ScanPlan struct {
func (plan *wrapInt64ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapInt64ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapInt64ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapInt64ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*int64Wrapper)(dst.(*int64))) return plan.next.Scan(src, (*int64Wrapper)(dst.(*int64)))
} }
@@ -762,7 +762,7 @@ type wrapIntScanPlan struct {
func (plan *wrapIntScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapIntScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapIntScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapIntScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*intWrapper)(dst.(*int))) return plan.next.Scan(src, (*intWrapper)(dst.(*int)))
} }
@@ -772,7 +772,7 @@ type wrapUint8ScanPlan struct {
func (plan *wrapUint8ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapUint8ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapUint8ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapUint8ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*uint8Wrapper)(dst.(*uint8))) return plan.next.Scan(src, (*uint8Wrapper)(dst.(*uint8)))
} }
@@ -782,7 +782,7 @@ type wrapUint16ScanPlan struct {
func (plan *wrapUint16ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapUint16ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapUint16ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapUint16ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*uint16Wrapper)(dst.(*uint16))) return plan.next.Scan(src, (*uint16Wrapper)(dst.(*uint16)))
} }
@@ -792,7 +792,7 @@ type wrapUint32ScanPlan struct {
func (plan *wrapUint32ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapUint32ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapUint32ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapUint32ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*uint32Wrapper)(dst.(*uint32))) return plan.next.Scan(src, (*uint32Wrapper)(dst.(*uint32)))
} }
@@ -802,7 +802,7 @@ type wrapUint64ScanPlan struct {
func (plan *wrapUint64ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapUint64ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapUint64ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapUint64ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*uint64Wrapper)(dst.(*uint64))) return plan.next.Scan(src, (*uint64Wrapper)(dst.(*uint64)))
} }
@@ -812,7 +812,7 @@ type wrapUintScanPlan struct {
func (plan *wrapUintScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapUintScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapUintScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapUintScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*uintWrapper)(dst.(*uint))) return plan.next.Scan(src, (*uintWrapper)(dst.(*uint)))
} }
@@ -822,7 +822,7 @@ type wrapFloat32ScanPlan struct {
func (plan *wrapFloat32ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapFloat32ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapFloat32ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapFloat32ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*float32Wrapper)(dst.(*float32))) return plan.next.Scan(src, (*float32Wrapper)(dst.(*float32)))
} }
@@ -832,7 +832,7 @@ type wrapFloat64ScanPlan struct {
func (plan *wrapFloat64ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapFloat64ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapFloat64ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapFloat64ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*float64Wrapper)(dst.(*float64))) return plan.next.Scan(src, (*float64Wrapper)(dst.(*float64)))
} }
@@ -842,7 +842,7 @@ type wrapStringScanPlan struct {
func (plan *wrapStringScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapStringScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapStringScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapStringScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*stringWrapper)(dst.(*string))) return plan.next.Scan(src, (*stringWrapper)(dst.(*string)))
} }
@@ -852,7 +852,7 @@ type wrapTimeScanPlan struct {
func (plan *wrapTimeScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapTimeScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapTimeScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapTimeScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*timeWrapper)(dst.(*time.Time))) return plan.next.Scan(src, (*timeWrapper)(dst.(*time.Time)))
} }
@@ -862,7 +862,7 @@ type wrapDurationScanPlan struct {
func (plan *wrapDurationScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapDurationScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapDurationScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapDurationScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*durationWrapper)(dst.(*time.Duration))) return plan.next.Scan(src, (*durationWrapper)(dst.(*time.Duration)))
} }
@@ -872,7 +872,7 @@ type wrapNetIPNetScanPlan struct {
func (plan *wrapNetIPNetScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapNetIPNetScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapNetIPNetScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapNetIPNetScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*netIPNetWrapper)(dst.(*net.IPNet))) return plan.next.Scan(src, (*netIPNetWrapper)(dst.(*net.IPNet)))
} }
@@ -882,7 +882,7 @@ type wrapNetIPScanPlan struct {
func (plan *wrapNetIPScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapNetIPScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapNetIPScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapNetIPScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*netIPWrapper)(dst.(*net.IP))) return plan.next.Scan(src, (*netIPWrapper)(dst.(*net.IP)))
} }
@@ -892,7 +892,7 @@ type wrapMapStringToPointerStringScanPlan struct {
func (plan *wrapMapStringToPointerStringScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapMapStringToPointerStringScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapMapStringToPointerStringScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapMapStringToPointerStringScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*mapStringToPointerStringWrapper)(dst.(*map[string]*string))) return plan.next.Scan(src, (*mapStringToPointerStringWrapper)(dst.(*map[string]*string)))
} }
@@ -902,7 +902,7 @@ type wrapMapStringToStringScanPlan struct {
func (plan *wrapMapStringToStringScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapMapStringToStringScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapMapStringToStringScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapMapStringToStringScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*mapStringToStringWrapper)(dst.(*map[string]string))) return plan.next.Scan(src, (*mapStringToStringWrapper)(dst.(*map[string]string)))
} }
@@ -912,7 +912,7 @@ type wrapByte16ScanPlan struct {
func (plan *wrapByte16ScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapByte16ScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapByte16ScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapByte16ScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*byte16Wrapper)(dst.(*[16]byte))) return plan.next.Scan(src, (*byte16Wrapper)(dst.(*[16]byte)))
} }
@@ -922,7 +922,7 @@ type wrapByteSliceScanPlan struct {
func (plan *wrapByteSliceScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapByteSliceScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapByteSliceScanPlan) Scan(src []byte, dst interface{}) error { func (plan *wrapByteSliceScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*byteSliceWrapper)(dst.(*[]byte))) return plan.next.Scan(src, (*byteSliceWrapper)(dst.(*[]byte)))
} }
@@ -933,20 +933,20 @@ type pointerEmptyInterfaceScanPlan struct {
formatCode int16 formatCode int16
} }
func (plan *pointerEmptyInterfaceScanPlan) Scan(src []byte, dst interface{}) error { func (plan *pointerEmptyInterfaceScanPlan) Scan(src []byte, dst any) error {
value, err := plan.codec.DecodeValue(plan.m, plan.oid, plan.formatCode, src) value, err := plan.codec.DecodeValue(plan.m, plan.oid, plan.formatCode, src)
if err != nil { if err != nil {
return err return err
} }
ptrAny := dst.(*interface{}) ptrAny := dst.(*any)
*ptrAny = value *ptrAny = value
return nil return nil
} }
// TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter. // TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter.
func TryWrapStructScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool) { func TryWrapStructScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool) {
targetValue := reflect.ValueOf(target) targetValue := reflect.ValueOf(target)
if targetValue.Kind() != reflect.Ptr { if targetValue.Kind() != reflect.Ptr {
return nil, nil, false return nil, nil, false
@@ -982,7 +982,7 @@ type wrapAnyPtrStructScanPlan struct {
func (plan *wrapAnyPtrStructScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapAnyPtrStructScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapAnyPtrStructScanPlan) Scan(src []byte, target interface{}) error { func (plan *wrapAnyPtrStructScanPlan) Scan(src []byte, target any) error {
w := ptrStructWrapper{ w := ptrStructWrapper{
s: target, s: target,
exportedFields: getExportedFieldValues(reflect.ValueOf(target).Elem()), exportedFields: getExportedFieldValues(reflect.ValueOf(target).Elem()),
@@ -992,7 +992,7 @@ func (plan *wrapAnyPtrStructScanPlan) Scan(src []byte, target interface{}) error
} }
// TryWrapPtrSliceScanPlan tries to wrap a pointer to a single dimension slice. // TryWrapPtrSliceScanPlan tries to wrap a pointer to a single dimension slice.
func TryWrapPtrSliceScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool) { func TryWrapPtrSliceScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool) {
targetValue := reflect.ValueOf(target) targetValue := reflect.ValueOf(target)
if targetValue.Kind() != reflect.Ptr { if targetValue.Kind() != reflect.Ptr {
return nil, nil, false return nil, nil, false
@@ -1012,12 +1012,12 @@ type wrapPtrSliceScanPlan struct {
func (plan *wrapPtrSliceScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapPtrSliceScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapPtrSliceScanPlan) Scan(src []byte, target interface{}) error { func (plan *wrapPtrSliceScanPlan) Scan(src []byte, target any) error {
return plan.next.Scan(src, &anySliceArray{slice: reflect.ValueOf(target).Elem()}) return plan.next.Scan(src, &anySliceArray{slice: reflect.ValueOf(target).Elem()})
} }
// TryWrapPtrMultiDimSliceScanPlan tries to wrap a pointer to a multi-dimension slice. // TryWrapPtrMultiDimSliceScanPlan tries to wrap a pointer to a multi-dimension slice.
func TryWrapPtrMultiDimSliceScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool) { func TryWrapPtrMultiDimSliceScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool) {
targetValue := reflect.ValueOf(target) targetValue := reflect.ValueOf(target)
if targetValue.Kind() != reflect.Ptr { if targetValue.Kind() != reflect.Ptr {
return nil, nil, false return nil, nil, false
@@ -1043,12 +1043,12 @@ type wrapPtrMultiDimSliceScanPlan struct {
func (plan *wrapPtrMultiDimSliceScanPlan) SetNext(next ScanPlan) { plan.next = next } func (plan *wrapPtrMultiDimSliceScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *wrapPtrMultiDimSliceScanPlan) Scan(src []byte, target interface{}) error { func (plan *wrapPtrMultiDimSliceScanPlan) Scan(src []byte, target any) error {
return plan.next.Scan(src, &anyMultiDimSliceArray{slice: reflect.ValueOf(target).Elem()}) return plan.next.Scan(src, &anyMultiDimSliceArray{slice: reflect.ValueOf(target).Elem()})
} }
// PlanScan prepares a plan to scan a value into target. // PlanScan prepares a plan to scan a value into target.
func (m *Map) PlanScan(oid uint32, formatCode int16, target interface{}) ScanPlan { func (m *Map) PlanScan(oid uint32, formatCode int16, target any) ScanPlan {
oidMemo := m.memoizedScanPlans[oid] oidMemo := m.memoizedScanPlans[oid]
if oidMemo == nil { if oidMemo == nil {
oidMemo = make(map[reflect.Type][2]ScanPlan) oidMemo = make(map[reflect.Type][2]ScanPlan)
@@ -1066,7 +1066,7 @@ func (m *Map) PlanScan(oid uint32, formatCode int16, target interface{}) ScanPla
return plan return plan
} }
func (m *Map) planScan(oid uint32, formatCode int16, target interface{}) ScanPlan { func (m *Map) planScan(oid uint32, formatCode int16, target any) ScanPlan {
if _, ok := target.(*UndecodedBytes); ok { if _, ok := target.(*UndecodedBytes); ok {
return scanPlanAnyToUndecodedBytes{} return scanPlanAnyToUndecodedBytes{}
} }
@@ -1120,7 +1120,7 @@ func (m *Map) planScan(oid uint32, formatCode int16, target interface{}) ScanPla
} }
if dt != nil { if dt != nil {
if _, ok := target.(*interface{}); ok { if _, ok := target.(*any); ok {
return &pointerEmptyInterfaceScanPlan{codec: dt.Codec, m: m, oid: oid, formatCode: formatCode} return &pointerEmptyInterfaceScanPlan{codec: dt.Codec, m: m, oid: oid, formatCode: formatCode}
} }
@@ -1136,7 +1136,7 @@ func (m *Map) planScan(oid uint32, formatCode int16, target interface{}) ScanPla
return &scanPlanFail{oid: oid, formatCode: formatCode} return &scanPlanFail{oid: oid, formatCode: formatCode}
} }
func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst interface{}) error { func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst any) error {
if dst == nil { if dst == nil {
return nil return nil
} }
@@ -1145,7 +1145,7 @@ func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst interface{}) er
return plan.Scan(src, dst) return plan.Scan(src, dst)
} }
func scanUnknownType(oid uint32, formatCode int16, buf []byte, dest interface{}) error { func scanUnknownType(oid uint32, formatCode int16, buf []byte, dest any) error {
switch dest := dest.(type) { switch dest := dest.(type) {
case *string: case *string:
if formatCode == BinaryFormatCode { if formatCode == BinaryFormatCode {
@@ -1166,7 +1166,7 @@ func scanUnknownType(oid uint32, formatCode int16, buf []byte, dest interface{})
var ErrScanTargetTypeChanged = errors.New("scan target type changed") var ErrScanTargetTypeChanged = errors.New("scan target type changed")
func codecScan(codec Codec, m *Map, oid uint32, format int16, src []byte, dst interface{}) error { func codecScan(codec Codec, m *Map, oid uint32, format int16, src []byte, dst any) error {
scanPlan := codec.PlanScan(m, oid, format, dst) scanPlan := codec.PlanScan(m, oid, format, dst)
if scanPlan == nil { if scanPlan == nil {
return fmt.Errorf("PlanScan did not find a plan") return fmt.Errorf("PlanScan did not find a plan")
@@ -1196,7 +1196,7 @@ func codecDecodeToTextFormat(codec Codec, m *Map, oid uint32, format int16, src
// PlanEncode returns an Encode plan for encoding value into PostgreSQL format for oid and format. If no plan can be // PlanEncode returns an Encode plan for encoding value into PostgreSQL format for oid and format. If no plan can be
// found then nil is returned. // found then nil is returned.
func (m *Map) PlanEncode(oid uint32, format int16, value interface{}) EncodePlan { func (m *Map) PlanEncode(oid uint32, format int16, value any) EncodePlan {
if format == TextFormatCode { if format == TextFormatCode {
switch value.(type) { switch value.(type) {
case string: case string:
@@ -1239,14 +1239,14 @@ func (m *Map) PlanEncode(oid uint32, format int16, value interface{}) EncodePlan
type encodePlanStringToAnyTextFormat struct{} type encodePlanStringToAnyTextFormat struct{}
func (encodePlanStringToAnyTextFormat) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanStringToAnyTextFormat) Encode(value any, buf []byte) (newBuf []byte, err error) {
s := value.(string) s := value.(string)
return append(buf, s...), nil return append(buf, s...), nil
} }
type encodePlanTextValuerToAnyTextFormat struct{} type encodePlanTextValuerToAnyTextFormat struct{}
func (encodePlanTextValuerToAnyTextFormat) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextValuerToAnyTextFormat) Encode(value any, buf []byte) (newBuf []byte, err error) {
t, err := value.(TextValuer).TextValue() t, err := value.(TextValuer).TextValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -1262,7 +1262,7 @@ func (encodePlanTextValuerToAnyTextFormat) Encode(value interface{}, buf []byte)
// that will convert the value passed to Encode and then call the next plan. nextValue is value as it will be converted // that will convert the value passed to Encode and then call the next plan. nextValue is value as it will be converted
// by plan. It must be used to find another suitable EncodePlan. When it is found SetNext must be called on plan for it // by plan. It must be used to find another suitable EncodePlan. When it is found SetNext must be called on plan for it
// to be usabled. ok indicates if a suitable wrapper was found. // to be usabled. ok indicates if a suitable wrapper was found.
type TryWrapEncodePlanFunc func(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) type TryWrapEncodePlanFunc func(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
type derefPointerEncodePlan struct { type derefPointerEncodePlan struct {
next EncodePlan next EncodePlan
@@ -1270,7 +1270,7 @@ type derefPointerEncodePlan struct {
func (plan *derefPointerEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *derefPointerEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *derefPointerEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *derefPointerEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
ptr := reflect.ValueOf(value) ptr := reflect.ValueOf(value)
if ptr.IsNil() { if ptr.IsNil() {
@@ -1282,7 +1282,7 @@ func (plan *derefPointerEncodePlan) Encode(value interface{}, buf []byte) (newBu
// TryWrapDerefPointerEncodePlan tries to dereference a pointer. e.g. If value was of type *string then a wrapper plan // TryWrapDerefPointerEncodePlan tries to dereference a pointer. e.g. If value was of type *string then a wrapper plan
// would be returned that derefences the value. // would be returned that derefences the value.
func TryWrapDerefPointerEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) { func TryWrapDerefPointerEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool) {
if valueType := reflect.TypeOf(value); valueType.Kind() == reflect.Ptr { if valueType := reflect.TypeOf(value); valueType.Kind() == reflect.Ptr {
return &derefPointerEncodePlan{}, reflect.New(valueType.Elem()).Elem().Interface(), true return &derefPointerEncodePlan{}, reflect.New(valueType.Elem()).Elem().Interface(), true
} }
@@ -1313,13 +1313,13 @@ type underlyingTypeEncodePlan struct {
func (plan *underlyingTypeEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *underlyingTypeEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *underlyingTypeEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *underlyingTypeEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(reflect.ValueOf(value).Convert(plan.nextValueType).Interface(), buf) return plan.next.Encode(reflect.ValueOf(value).Convert(plan.nextValueType).Interface(), buf)
} }
// TryWrapFindUnderlyingTypeEncodePlan tries to convert to a Go builtin type. e.g. If value was of type MyString and // TryWrapFindUnderlyingTypeEncodePlan tries to convert to a Go builtin type. e.g. If value was of type MyString and
// MyString was defined as a string then a wrapper plan would be returned that converts MyString to string. // MyString was defined as a string then a wrapper plan would be returned that converts MyString to string.
func TryWrapFindUnderlyingTypeEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) { func TryWrapFindUnderlyingTypeEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool) {
if _, ok := value.(SkipUnderlyingTypePlanner); ok { if _, ok := value.(SkipUnderlyingTypePlanner); ok {
return nil, nil, false return nil, nil, false
} }
@@ -1342,7 +1342,7 @@ type WrappedEncodePlanNextSetter interface {
// TryWrapBuiltinTypeEncodePlan tries to wrap a builtin type with a wrapper that provides additional methods. e.g. If // TryWrapBuiltinTypeEncodePlan tries to wrap a builtin type with a wrapper that provides additional methods. e.g. If
// value was of type int32 then a wrapper plan would be returned that converts value to a type that implements // value was of type int32 then a wrapper plan would be returned that converts value to a type that implements
// Int64Valuer. // Int64Valuer.
func TryWrapBuiltinTypeEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) { func TryWrapBuiltinTypeEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool) {
switch value := value.(type) { switch value := value.(type) {
case int8: case int8:
return &wrapInt8EncodePlan{}, int8Wrapper(value), true return &wrapInt8EncodePlan{}, int8Wrapper(value), true
@@ -1399,7 +1399,7 @@ type wrapInt8EncodePlan struct {
func (plan *wrapInt8EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapInt8EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapInt8EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapInt8EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(int8Wrapper(value.(int8)), buf) return plan.next.Encode(int8Wrapper(value.(int8)), buf)
} }
@@ -1409,7 +1409,7 @@ type wrapInt16EncodePlan struct {
func (plan *wrapInt16EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapInt16EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapInt16EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapInt16EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(int16Wrapper(value.(int16)), buf) return plan.next.Encode(int16Wrapper(value.(int16)), buf)
} }
@@ -1419,7 +1419,7 @@ type wrapInt32EncodePlan struct {
func (plan *wrapInt32EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapInt32EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapInt32EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapInt32EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(int32Wrapper(value.(int32)), buf) return plan.next.Encode(int32Wrapper(value.(int32)), buf)
} }
@@ -1429,7 +1429,7 @@ type wrapInt64EncodePlan struct {
func (plan *wrapInt64EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapInt64EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapInt64EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapInt64EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(int64Wrapper(value.(int64)), buf) return plan.next.Encode(int64Wrapper(value.(int64)), buf)
} }
@@ -1439,7 +1439,7 @@ type wrapIntEncodePlan struct {
func (plan *wrapIntEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapIntEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapIntEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapIntEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(intWrapper(value.(int)), buf) return plan.next.Encode(intWrapper(value.(int)), buf)
} }
@@ -1449,7 +1449,7 @@ type wrapUint8EncodePlan struct {
func (plan *wrapUint8EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapUint8EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapUint8EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapUint8EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(uint8Wrapper(value.(uint8)), buf) return plan.next.Encode(uint8Wrapper(value.(uint8)), buf)
} }
@@ -1459,7 +1459,7 @@ type wrapUint16EncodePlan struct {
func (plan *wrapUint16EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapUint16EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapUint16EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapUint16EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(uint16Wrapper(value.(uint16)), buf) return plan.next.Encode(uint16Wrapper(value.(uint16)), buf)
} }
@@ -1469,7 +1469,7 @@ type wrapUint32EncodePlan struct {
func (plan *wrapUint32EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapUint32EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapUint32EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapUint32EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(uint32Wrapper(value.(uint32)), buf) return plan.next.Encode(uint32Wrapper(value.(uint32)), buf)
} }
@@ -1479,7 +1479,7 @@ type wrapUint64EncodePlan struct {
func (plan *wrapUint64EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapUint64EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapUint64EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapUint64EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(uint64Wrapper(value.(uint64)), buf) return plan.next.Encode(uint64Wrapper(value.(uint64)), buf)
} }
@@ -1489,7 +1489,7 @@ type wrapUintEncodePlan struct {
func (plan *wrapUintEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapUintEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapUintEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapUintEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(uintWrapper(value.(uint)), buf) return plan.next.Encode(uintWrapper(value.(uint)), buf)
} }
@@ -1499,7 +1499,7 @@ type wrapFloat32EncodePlan struct {
func (plan *wrapFloat32EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapFloat32EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapFloat32EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapFloat32EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(float32Wrapper(value.(float32)), buf) return plan.next.Encode(float32Wrapper(value.(float32)), buf)
} }
@@ -1509,7 +1509,7 @@ type wrapFloat64EncodePlan struct {
func (plan *wrapFloat64EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapFloat64EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapFloat64EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapFloat64EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(float64Wrapper(value.(float64)), buf) return plan.next.Encode(float64Wrapper(value.(float64)), buf)
} }
@@ -1519,7 +1519,7 @@ type wrapStringEncodePlan struct {
func (plan *wrapStringEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapStringEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapStringEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapStringEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(stringWrapper(value.(string)), buf) return plan.next.Encode(stringWrapper(value.(string)), buf)
} }
@@ -1529,7 +1529,7 @@ type wrapTimeEncodePlan struct {
func (plan *wrapTimeEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapTimeEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapTimeEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapTimeEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(timeWrapper(value.(time.Time)), buf) return plan.next.Encode(timeWrapper(value.(time.Time)), buf)
} }
@@ -1539,7 +1539,7 @@ type wrapDurationEncodePlan struct {
func (plan *wrapDurationEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapDurationEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapDurationEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapDurationEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(durationWrapper(value.(time.Duration)), buf) return plan.next.Encode(durationWrapper(value.(time.Duration)), buf)
} }
@@ -1549,7 +1549,7 @@ type wrapNetIPNetEncodePlan struct {
func (plan *wrapNetIPNetEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapNetIPNetEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapNetIPNetEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapNetIPNetEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(netIPNetWrapper(value.(net.IPNet)), buf) return plan.next.Encode(netIPNetWrapper(value.(net.IPNet)), buf)
} }
@@ -1559,7 +1559,7 @@ type wrapNetIPEncodePlan struct {
func (plan *wrapNetIPEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapNetIPEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapNetIPEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapNetIPEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(netIPWrapper(value.(net.IP)), buf) return plan.next.Encode(netIPWrapper(value.(net.IP)), buf)
} }
@@ -1569,7 +1569,7 @@ type wrapMapStringToPointerStringEncodePlan struct {
func (plan *wrapMapStringToPointerStringEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapMapStringToPointerStringEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapMapStringToPointerStringEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapMapStringToPointerStringEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(mapStringToPointerStringWrapper(value.(map[string]*string)), buf) return plan.next.Encode(mapStringToPointerStringWrapper(value.(map[string]*string)), buf)
} }
@@ -1579,7 +1579,7 @@ type wrapMapStringToStringEncodePlan struct {
func (plan *wrapMapStringToStringEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapMapStringToStringEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapMapStringToStringEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapMapStringToStringEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(mapStringToStringWrapper(value.(map[string]string)), buf) return plan.next.Encode(mapStringToStringWrapper(value.(map[string]string)), buf)
} }
@@ -1589,7 +1589,7 @@ type wrapByte16EncodePlan struct {
func (plan *wrapByte16EncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapByte16EncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapByte16EncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapByte16EncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(byte16Wrapper(value.([16]byte)), buf) return plan.next.Encode(byte16Wrapper(value.([16]byte)), buf)
} }
@@ -1599,7 +1599,7 @@ type wrapByteSliceEncodePlan struct {
func (plan *wrapByteSliceEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapByteSliceEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapByteSliceEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapByteSliceEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(byteSliceWrapper(value.([]byte)), buf) return plan.next.Encode(byteSliceWrapper(value.([]byte)), buf)
} }
@@ -1609,12 +1609,12 @@ type wrapFmtStringerEncodePlan struct {
func (plan *wrapFmtStringerEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapFmtStringerEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapFmtStringerEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapFmtStringerEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(fmtStringerWrapper{value.(fmt.Stringer)}, buf) return plan.next.Encode(fmtStringerWrapper{value.(fmt.Stringer)}, buf)
} }
// TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter. // TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter.
func TryWrapStructEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) { func TryWrapStructEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool) {
if reflect.TypeOf(value).Kind() == reflect.Struct { if reflect.TypeOf(value).Kind() == reflect.Struct {
exportedFields := getExportedFieldValues(reflect.ValueOf(value)) exportedFields := getExportedFieldValues(reflect.ValueOf(value))
if len(exportedFields) == 0 { if len(exportedFields) == 0 {
@@ -1637,7 +1637,7 @@ type wrapAnyStructEncodePlan struct {
func (plan *wrapAnyStructEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapAnyStructEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapAnyStructEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapAnyStructEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
w := structWrapper{ w := structWrapper{
s: value, s: value,
exportedFields: getExportedFieldValues(reflect.ValueOf(value)), exportedFields: getExportedFieldValues(reflect.ValueOf(value)),
@@ -1659,7 +1659,7 @@ func getExportedFieldValues(structValue reflect.Value) []reflect.Value {
return exportedFields return exportedFields
} }
func TryWrapSliceEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) { func TryWrapSliceEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool) {
if reflect.TypeOf(value).Kind() == reflect.Slice { if reflect.TypeOf(value).Kind() == reflect.Slice {
w := anySliceArray{ w := anySliceArray{
slice: reflect.ValueOf(value), slice: reflect.ValueOf(value),
@@ -1676,7 +1676,7 @@ type wrapSliceEncodePlan struct {
func (plan *wrapSliceEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapSliceEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapSliceEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapSliceEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
w := anySliceArray{ w := anySliceArray{
slice: reflect.ValueOf(value), slice: reflect.ValueOf(value),
} }
@@ -1684,7 +1684,7 @@ func (plan *wrapSliceEncodePlan) Encode(value interface{}, buf []byte) (newBuf [
return plan.next.Encode(w, buf) return plan.next.Encode(w, buf)
} }
func TryWrapMultiDimSliceEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) { func TryWrapMultiDimSliceEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool) {
sliceValue := reflect.ValueOf(value) sliceValue := reflect.ValueOf(value)
if sliceValue.Kind() == reflect.Slice { if sliceValue.Kind() == reflect.Slice {
valueElemType := sliceValue.Type().Elem() valueElemType := sliceValue.Type().Elem()
@@ -1708,7 +1708,7 @@ type wrapMultiDimSliceEncodePlan struct {
func (plan *wrapMultiDimSliceEncodePlan) SetNext(next EncodePlan) { plan.next = next } func (plan *wrapMultiDimSliceEncodePlan) SetNext(next EncodePlan) { plan.next = next }
func (plan *wrapMultiDimSliceEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *wrapMultiDimSliceEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
w := anyMultiDimSliceArray{ w := anyMultiDimSliceArray{
slice: reflect.ValueOf(value), slice: reflect.ValueOf(value),
} }
@@ -1719,7 +1719,7 @@ func (plan *wrapMultiDimSliceEncodePlan) Encode(value interface{}, buf []byte) (
// Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return // Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return
// (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data // (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data
// written. // written.
func (m *Map) Encode(oid uint32, formatCode int16, value interface{}, buf []byte) (newBuf []byte, err error) { func (m *Map) Encode(oid uint32, formatCode int16, value any, buf []byte) (newBuf []byte, err error) {
if value == nil { if value == nil {
return nil, nil return nil, nil
} }
+4 -4
View File
@@ -125,7 +125,7 @@ func TestTypeMapScanNilIsNoOp(t *testing.T) {
func TestTypeMapScanTextFormatInterfacePtr(t *testing.T) { func TestTypeMapScanTextFormatInterfacePtr(t *testing.T) {
m := pgtype.NewMap() m := pgtype.NewMap()
var got interface{} var got any
err := m.Scan(pgtype.TextOID, pgx.TextFormatCode, []byte("foo"), &got) err := m.Scan(pgtype.TextOID, pgx.TextFormatCode, []byte("foo"), &got)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, "foo", got) assert.Equal(t, "foo", got)
@@ -141,7 +141,7 @@ func TestTypeMapScanTextFormatNonByteaIntoByteSlice(t *testing.T) {
func TestTypeMapScanBinaryFormatInterfacePtr(t *testing.T) { func TestTypeMapScanBinaryFormatInterfacePtr(t *testing.T) {
m := pgtype.NewMap() m := pgtype.NewMap()
var got interface{} var got any
err := m.Scan(pgtype.TextOID, pgx.BinaryFormatCode, []byte("foo"), &got) err := m.Scan(pgtype.TextOID, pgx.BinaryFormatCode, []byte("foo"), &got)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, "foo", got) assert.Equal(t, "foo", got)
@@ -273,8 +273,8 @@ func BenchmarkScanPlanScanInt4IntoGoInt32(b *testing.B) {
} }
} }
func isExpectedEq(a interface{}) func(interface{}) bool { func isExpectedEq(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
return a == v return a == v
} }
} }
+8 -8
View File
@@ -69,7 +69,7 @@ func parsePoint(src []byte) (*Point, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Point) Scan(src interface{}) error { func (dst *Point) Scan(src any) error {
if src == nil { if src == nil {
*dst = Point{} *dst = Point{}
return nil return nil
@@ -127,7 +127,7 @@ func (PointCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (PointCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (PointCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(PointValuer); !ok { if _, ok := value.(PointValuer); !ok {
return nil return nil
} }
@@ -144,7 +144,7 @@ func (PointCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}
type encodePlanPointCodecBinary struct{} type encodePlanPointCodecBinary struct{}
func (encodePlanPointCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanPointCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
point, err := value.(PointValuer).PointValue() point, err := value.(PointValuer).PointValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -161,7 +161,7 @@ func (encodePlanPointCodecBinary) Encode(value interface{}, buf []byte) (newBuf
type encodePlanPointCodecText struct{} type encodePlanPointCodecText struct{}
func (encodePlanPointCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanPointCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
point, err := value.(PointValuer).PointValue() point, err := value.(PointValuer).PointValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -177,7 +177,7 @@ func (encodePlanPointCodecText) Encode(value interface{}, buf []byte) (newBuf []
)...), nil )...), nil
} }
func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -199,7 +199,7 @@ func (c PointCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c PointCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c PointCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -214,7 +214,7 @@ func (c PointCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (i
type scanPlanBinaryPointToPointScanner struct{} type scanPlanBinaryPointToPointScanner struct{}
func (scanPlanBinaryPointToPointScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryPointToPointScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PointScanner) scanner := (dst).(PointScanner)
if src == nil { if src == nil {
@@ -236,7 +236,7 @@ func (scanPlanBinaryPointToPointScanner) Scan(src []byte, dst interface{}) error
type scanPlanTextAnyToPointScanner struct{} type scanPlanTextAnyToPointScanner struct{}
func (scanPlanTextAnyToPointScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToPointScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PointScanner) scanner := (dst).(PointScanner)
if src == nil { if src == nil {
+8 -8
View File
@@ -34,7 +34,7 @@ func (p Polygon) PolygonValue() (Polygon, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (p *Polygon) Scan(src interface{}) error { func (p *Polygon) Scan(src any) error {
if src == nil { if src == nil {
*p = Polygon{} *p = Polygon{}
return nil return nil
@@ -72,7 +72,7 @@ func (PolygonCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (PolygonCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (PolygonCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(PolygonValuer); !ok { if _, ok := value.(PolygonValuer); !ok {
return nil return nil
} }
@@ -89,7 +89,7 @@ func (PolygonCodec) PlanEncode(m *Map, oid uint32, format int16, value interface
type encodePlanPolygonCodecBinary struct{} type encodePlanPolygonCodecBinary struct{}
func (encodePlanPolygonCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanPolygonCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
polygon, err := value.(PolygonValuer).PolygonValue() polygon, err := value.(PolygonValuer).PolygonValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -111,7 +111,7 @@ func (encodePlanPolygonCodecBinary) Encode(value interface{}, buf []byte) (newBu
type encodePlanPolygonCodecText struct{} type encodePlanPolygonCodecText struct{}
func (encodePlanPolygonCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanPolygonCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
polygon, err := value.(PolygonValuer).PolygonValue() polygon, err := value.(PolygonValuer).PolygonValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -138,7 +138,7 @@ func (encodePlanPolygonCodecText) Encode(value interface{}, buf []byte) (newBuf
return buf, nil return buf, nil
} }
func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -158,7 +158,7 @@ func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target interface{
type scanPlanBinaryPolygonToPolygonScanner struct{} type scanPlanBinaryPolygonToPolygonScanner struct{}
func (scanPlanBinaryPolygonToPolygonScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryPolygonToPolygonScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PolygonScanner) scanner := (dst).(PolygonScanner)
if src == nil { if src == nil {
@@ -193,7 +193,7 @@ func (scanPlanBinaryPolygonToPolygonScanner) Scan(src []byte, dst interface{}) e
type scanPlanTextAnyToPolygonScanner struct{} type scanPlanTextAnyToPolygonScanner struct{}
func (scanPlanTextAnyToPolygonScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToPolygonScanner) Scan(src []byte, dst any) error {
scanner := (dst).(PolygonScanner) scanner := (dst).(PolygonScanner)
if src == nil { if src == nil {
@@ -239,7 +239,7 @@ func (c PolygonCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, s
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c PolygonCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c PolygonCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqPolygon(a interface{}) func(interface{}) bool { func isExpectedEqPolygon(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
ap := a.(pgtype.Polygon) ap := a.(pgtype.Polygon)
vp := v.(pgtype.Polygon) vp := v.(pgtype.Polygon)
+7 -7
View File
@@ -22,7 +22,7 @@ func (QCharCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (QCharCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (QCharCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case TextFormatCode, BinaryFormatCode: case TextFormatCode, BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -38,7 +38,7 @@ func (QCharCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}
type encodePlanQcharCodecByte struct{} type encodePlanQcharCodecByte struct{}
func (encodePlanQcharCodecByte) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanQcharCodecByte) Encode(value any, buf []byte) (newBuf []byte, err error) {
b := value.(byte) b := value.(byte)
buf = append(buf, b) buf = append(buf, b)
return buf, nil return buf, nil
@@ -46,7 +46,7 @@ func (encodePlanQcharCodecByte) Encode(value interface{}, buf []byte) (newBuf []
type encodePlanQcharCodecRune struct{} type encodePlanQcharCodecRune struct{}
func (encodePlanQcharCodecRune) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanQcharCodecRune) Encode(value any, buf []byte) (newBuf []byte, err error) {
r := value.(rune) r := value.(rune)
if r > math.MaxUint8 { if r > math.MaxUint8 {
return nil, fmt.Errorf(`%v cannot be encoded to "char"`, r) return nil, fmt.Errorf(`%v cannot be encoded to "char"`, r)
@@ -56,7 +56,7 @@ func (encodePlanQcharCodecRune) Encode(value interface{}, buf []byte) (newBuf []
return buf, nil return buf, nil
} }
func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case TextFormatCode, BinaryFormatCode: case TextFormatCode, BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -72,7 +72,7 @@ func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanQcharCodecByte struct{} type scanPlanQcharCodecByte struct{}
func (scanPlanQcharCodecByte) Scan(src []byte, dst interface{}) error { func (scanPlanQcharCodecByte) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -94,7 +94,7 @@ func (scanPlanQcharCodecByte) Scan(src []byte, dst interface{}) error {
type scanPlanQcharCodecRune struct{} type scanPlanQcharCodecRune struct{}
func (scanPlanQcharCodecRune) Scan(src []byte, dst interface{}) error { func (scanPlanQcharCodecRune) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -127,7 +127,7 @@ func (c QCharCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return string(r), nil return string(r), nil
} }
func (c QCharCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c QCharCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+13 -13
View File
@@ -16,7 +16,7 @@ type RangeValuer interface {
BoundTypes() (lower, upper BoundType) BoundTypes() (lower, upper BoundType)
// Bounds returns the lower and upper range values. // Bounds returns the lower and upper range values.
Bounds() (lower, upper interface{}) Bounds() (lower, upper any)
} }
// RangeScanner is a type can be scanned from a PostgreSQL range. // RangeScanner is a type can be scanned from a PostgreSQL range.
@@ -26,7 +26,7 @@ type RangeScanner interface {
// ScanBounds returns values usable as a scan target. The returned values may not be scanned if the range is empty or // ScanBounds returns values usable as a scan target. The returned values may not be scanned if the range is empty or
// the bound type is unbounded. // the bound type is unbounded.
ScanBounds() (lowerTarget, upperTarget interface{}) ScanBounds() (lowerTarget, upperTarget any)
// SetBoundTypes sets the lower and upper bound types. ScanBounds will be called and the returned values scanned // SetBoundTypes sets the lower and upper bound types. ScanBounds will be called and the returned values scanned
// (if appropriate) before SetBoundTypes is called. If the bound types are unbounded or empty this method must // (if appropriate) before SetBoundTypes is called. If the bound types are unbounded or empty this method must
@@ -35,8 +35,8 @@ type RangeScanner interface {
} }
type GenericRange struct { type GenericRange struct {
Lower interface{} Lower any
Upper interface{} Upper any
LowerType BoundType LowerType BoundType
UpperType BoundType UpperType BoundType
Valid bool Valid bool
@@ -50,7 +50,7 @@ func (r GenericRange) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r GenericRange) Bounds() (lower, upper interface{}) { func (r GenericRange) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -59,7 +59,7 @@ func (r *GenericRange) ScanNull() error {
return nil return nil
} }
func (r *GenericRange) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *GenericRange) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -86,7 +86,7 @@ func (c *RangeCodec) PreferredFormat() int16 {
return TextFormatCode return TextFormatCode
} }
func (c *RangeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (c *RangeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(RangeValuer); !ok { if _, ok := value.(RangeValuer); !ok {
return nil return nil
} }
@@ -106,7 +106,7 @@ type encodePlanRangeCodecRangeValuerToBinary struct {
m *Map m *Map
} }
func (plan *encodePlanRangeCodecRangeValuerToBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *encodePlanRangeCodecRangeValuerToBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
getter := value.(RangeValuer) getter := value.(RangeValuer)
if getter.IsNull() { if getter.IsNull() {
@@ -197,7 +197,7 @@ type encodePlanRangeCodecRangeValuerToText struct {
m *Map m *Map
} }
func (plan *encodePlanRangeCodecRangeValuerToText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (plan *encodePlanRangeCodecRangeValuerToText) Encode(value any, buf []byte) (newBuf []byte, err error) {
getter := value.(RangeValuer) getter := value.(RangeValuer)
if getter.IsNull() { if getter.IsNull() {
@@ -270,7 +270,7 @@ func (plan *encodePlanRangeCodecRangeValuerToText) Encode(value interface{}, buf
return buf, nil return buf, nil
} }
func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -292,7 +292,7 @@ type scanPlanBinaryRangeToRangeScanner struct {
m *Map m *Map
} }
func (plan *scanPlanBinaryRangeToRangeScanner) Scan(src []byte, target interface{}) error { func (plan *scanPlanBinaryRangeToRangeScanner) Scan(src []byte, target any) error {
rangeScanner := (target).(RangeScanner) rangeScanner := (target).(RangeScanner)
if src == nil { if src == nil {
@@ -342,7 +342,7 @@ type scanPlanTextRangeToRangeScanner struct {
m *Map m *Map
} }
func (plan *scanPlanTextRangeToRangeScanner) Scan(src []byte, target interface{}) error { func (plan *scanPlanTextRangeToRangeScanner) Scan(src []byte, target any) error {
rangeScanner := (target).(RangeScanner) rangeScanner := (target).(RangeScanner)
if src == nil { if src == nil {
@@ -404,7 +404,7 @@ func (c *RangeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
} }
} }
func (c *RangeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c *RangeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+1 -1
View File
@@ -132,7 +132,7 @@ func TestRangeCodecDecodeValue(t *testing.T) {
for _, tt := range []struct { for _, tt := range []struct {
sql string sql string
expected interface{} expected any
}{ }{
{ {
sql: `select '[1,5)'::int4range`, sql: `select '[1,5)'::int4range`,
+14 -14
View File
@@ -17,7 +17,7 @@ func (r Int4range) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Int4range) Bounds() (lower, upper interface{}) { func (r Int4range) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -26,7 +26,7 @@ func (r *Int4range) ScanNull() error {
return nil return nil
} }
func (r *Int4range) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Int4range) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -59,7 +59,7 @@ func (r Int8range) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Int8range) Bounds() (lower, upper interface{}) { func (r Int8range) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -68,7 +68,7 @@ func (r *Int8range) ScanNull() error {
return nil return nil
} }
func (r *Int8range) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Int8range) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -101,7 +101,7 @@ func (r Numrange) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Numrange) Bounds() (lower, upper interface{}) { func (r Numrange) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -110,7 +110,7 @@ func (r *Numrange) ScanNull() error {
return nil return nil
} }
func (r *Numrange) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Numrange) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -143,7 +143,7 @@ func (r Tsrange) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Tsrange) Bounds() (lower, upper interface{}) { func (r Tsrange) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -152,7 +152,7 @@ func (r *Tsrange) ScanNull() error {
return nil return nil
} }
func (r *Tsrange) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Tsrange) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -185,7 +185,7 @@ func (r Tstzrange) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Tstzrange) Bounds() (lower, upper interface{}) { func (r Tstzrange) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -194,7 +194,7 @@ func (r *Tstzrange) ScanNull() error {
return nil return nil
} }
func (r *Tstzrange) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Tstzrange) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -227,7 +227,7 @@ func (r Daterange) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Daterange) Bounds() (lower, upper interface{}) { func (r Daterange) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -236,7 +236,7 @@ func (r *Daterange) ScanNull() error {
return nil return nil
} }
func (r *Daterange) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Daterange) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -269,7 +269,7 @@ func (r Float8range) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r Float8range) Bounds() (lower, upper interface{}) { func (r Float8range) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -278,7 +278,7 @@ func (r *Float8range) ScanNull() error {
return nil return nil
} }
func (r *Float8range) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *Float8range) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
+2 -2
View File
@@ -27,7 +27,7 @@ func (r <%= range_type %>) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType return r.LowerType, r.UpperType
} }
func (r <%= range_type %>) Bounds() (lower, upper interface{}) { func (r <%= range_type %>) Bounds() (lower, upper any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
@@ -36,7 +36,7 @@ func (r *<%= range_type %>) ScanNull() error {
return nil return nil
} }
func (r *<%= range_type %>) ScanBounds() (lowerTarget, upperTarget interface{}) { func (r *<%= range_type %>) ScanBounds() (lowerTarget, upperTarget any) {
return &r.Lower, &r.Upper return &r.Lower, &r.Upper
} }
+6 -6
View File
@@ -21,11 +21,11 @@ func (RecordCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (RecordCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (RecordCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
return nil return nil
} }
func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
if format == BinaryFormatCode { if format == BinaryFormatCode {
switch target.(type) { switch target.(type) {
case CompositeIndexScanner: case CompositeIndexScanner:
@@ -40,7 +40,7 @@ type scanPlanBinaryRecordToCompositeIndexScanner struct {
m *Map m *Map
} }
func (plan *scanPlanBinaryRecordToCompositeIndexScanner) Scan(src []byte, target interface{}) error { func (plan *scanPlanBinaryRecordToCompositeIndexScanner) Scan(src []byte, target any) error {
targetScanner := (target).(CompositeIndexScanner) targetScanner := (target).(CompositeIndexScanner)
if src == nil { if src == nil {
@@ -87,7 +87,7 @@ func (RecordCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
} }
} }
func (RecordCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (RecordCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -97,9 +97,9 @@ func (RecordCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
return string(src), nil return string(src), nil
case BinaryFormatCode: case BinaryFormatCode:
scanner := NewCompositeBinaryScanner(m, src) scanner := NewCompositeBinaryScanner(m, src)
values := make([]interface{}, scanner.FieldCount()) values := make([]any, scanner.FieldCount())
for i := 0; scanner.Next(); i++ { for i := 0; scanner.Next(); i++ {
var v interface{} var v any
fieldPlan := m.PlanScan(scanner.OID(), BinaryFormatCode, &v) fieldPlan := m.PlanScan(scanner.OID(), BinaryFormatCode, &v)
if fieldPlan == nil { if fieldPlan == nil {
return nil, fmt.Errorf("unable to scan OID %d in binary format into %v", scanner.OID(), v) return nil, fmt.Errorf("unable to scan OID %d in binary format into %v", scanner.OID(), v)
+6 -6
View File
@@ -27,27 +27,27 @@ func TestRecordCodecDecodeValue(t *testing.T) {
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) { defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) {
for _, tt := range []struct { for _, tt := range []struct {
sql string sql string
expected interface{} expected any
}{ }{
{ {
sql: `select row()`, sql: `select row()`,
expected: []interface{}{}, expected: []any{},
}, },
{ {
sql: `select row('foo'::text, 42::int4)`, sql: `select row('foo'::text, 42::int4)`,
expected: []interface{}{"foo", int32(42)}, expected: []any{"foo", int32(42)},
}, },
{ {
sql: `select row(100.0::float4, 1.09::float4)`, sql: `select row(100.0::float4, 1.09::float4)`,
expected: []interface{}{float32(100), float32(1.09)}, expected: []any{float32(100), float32(1.09)},
}, },
{ {
sql: `select row('foo'::text, array[1, 2, null, 4]::int4[], 42::int4)`, sql: `select row('foo'::text, array[1, 2, null, 4]::int4[], 42::int4)`,
expected: []interface{}{"foo", []interface{}{int32(1), int32(2), nil, int32(4)}, int32(42)}, expected: []any{"foo", []any{int32(1), int32(2), nil, int32(4)}, int32(42)},
}, },
{ {
sql: `select row(null)`, sql: `select row(null)`,
expected: []interface{}{nil}, expected: []any{nil},
}, },
{ {
sql: `select null::record`, sql: `select null::record`,
+14 -14
View File
@@ -30,7 +30,7 @@ func (t Text) TextValue() (Text, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Text) Scan(src interface{}) error { func (dst *Text) Scan(src any) error {
if src == nil { if src == nil {
*dst = Text{} *dst = Text{}
return nil return nil
@@ -90,7 +90,7 @@ func (TextCodec) PreferredFormat() int16 {
return TextFormatCode return TextFormatCode
} }
func (TextCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (TextCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case TextFormatCode, BinaryFormatCode: case TextFormatCode, BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -110,7 +110,7 @@ func (TextCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanTextCodecString struct{} type encodePlanTextCodecString struct{}
func (encodePlanTextCodecString) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextCodecString) Encode(value any, buf []byte) (newBuf []byte, err error) {
s := value.(string) s := value.(string)
buf = append(buf, s...) buf = append(buf, s...)
return buf, nil return buf, nil
@@ -118,7 +118,7 @@ func (encodePlanTextCodecString) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanTextCodecByteSlice struct{} type encodePlanTextCodecByteSlice struct{}
func (encodePlanTextCodecByteSlice) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextCodecByteSlice) Encode(value any, buf []byte) (newBuf []byte, err error) {
s := value.([]byte) s := value.([]byte)
buf = append(buf, s...) buf = append(buf, s...)
return buf, nil return buf, nil
@@ -126,7 +126,7 @@ func (encodePlanTextCodecByteSlice) Encode(value interface{}, buf []byte) (newBu
type encodePlanTextCodecRune struct{} type encodePlanTextCodecRune struct{}
func (encodePlanTextCodecRune) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextCodecRune) Encode(value any, buf []byte) (newBuf []byte, err error) {
r := value.(rune) r := value.(rune)
buf = append(buf, string(r)...) buf = append(buf, string(r)...)
return buf, nil return buf, nil
@@ -134,7 +134,7 @@ func (encodePlanTextCodecRune) Encode(value interface{}, buf []byte) (newBuf []b
type encodePlanTextCodecStringer struct{} type encodePlanTextCodecStringer struct{}
func (encodePlanTextCodecStringer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextCodecStringer) Encode(value any, buf []byte) (newBuf []byte, err error) {
s := value.(fmt.Stringer) s := value.(fmt.Stringer)
buf = append(buf, s.String()...) buf = append(buf, s.String()...)
return buf, nil return buf, nil
@@ -142,7 +142,7 @@ func (encodePlanTextCodecStringer) Encode(value interface{}, buf []byte) (newBuf
type encodePlanTextCodecTextValuer struct{} type encodePlanTextCodecTextValuer struct{}
func (encodePlanTextCodecTextValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTextCodecTextValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
text, err := value.(TextValuer).TextValue() text, err := value.(TextValuer).TextValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -156,7 +156,7 @@ func (encodePlanTextCodecTextValuer) Encode(value interface{}, buf []byte) (newB
return buf, nil return buf, nil
} }
func (TextCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (TextCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case TextFormatCode, BinaryFormatCode: case TextFormatCode, BinaryFormatCode:
@@ -181,7 +181,7 @@ func (c TextCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return c.DecodeValue(m, oid, format, src) return c.DecodeValue(m, oid, format, src)
} }
func (c TextCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c TextCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -191,7 +191,7 @@ func (c TextCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
type scanPlanTextAnyToString struct{} type scanPlanTextAnyToString struct{}
func (scanPlanTextAnyToString) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToString) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -204,7 +204,7 @@ func (scanPlanTextAnyToString) Scan(src []byte, dst interface{}) error {
type scanPlanAnyToNewByteSlice struct{} type scanPlanAnyToNewByteSlice struct{}
func (scanPlanAnyToNewByteSlice) Scan(src []byte, dst interface{}) error { func (scanPlanAnyToNewByteSlice) Scan(src []byte, dst any) error {
p := (dst).(*[]byte) p := (dst).(*[]byte)
if src == nil { if src == nil {
*p = nil *p = nil
@@ -218,14 +218,14 @@ func (scanPlanAnyToNewByteSlice) Scan(src []byte, dst interface{}) error {
type scanPlanAnyToByteScanner struct{} type scanPlanAnyToByteScanner struct{}
func (scanPlanAnyToByteScanner) Scan(src []byte, dst interface{}) error { func (scanPlanAnyToByteScanner) Scan(src []byte, dst any) error {
p := (dst).(BytesScanner) p := (dst).(BytesScanner)
return p.ScanBytes(src) return p.ScanBytes(src)
} }
type scanPlanTextAnyToRune struct{} type scanPlanTextAnyToRune struct{}
func (scanPlanTextAnyToRune) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToRune) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -243,7 +243,7 @@ func (scanPlanTextAnyToRune) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToTextScanner struct{} type scanPlanTextAnyToTextScanner struct{}
func (scanPlanTextAnyToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToTextScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TextScanner) scanner := (dst).(TextScanner)
if src == nil { if src == nil {
+9 -9
View File
@@ -45,7 +45,7 @@ func (b TID) TIDValue() (TID, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *TID) Scan(src interface{}) error { func (dst *TID) Scan(src any) error {
if src == nil { if src == nil {
*dst = TID{} *dst = TID{}
return nil return nil
@@ -82,7 +82,7 @@ func (TIDCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (TIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (TIDCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(TIDValuer); !ok { if _, ok := value.(TIDValuer); !ok {
return nil return nil
} }
@@ -99,7 +99,7 @@ func (TIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanTIDCodecBinary struct{} type encodePlanTIDCodecBinary struct{}
func (encodePlanTIDCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTIDCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
tid, err := value.(TIDValuer).TIDValue() tid, err := value.(TIDValuer).TIDValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -116,7 +116,7 @@ func (encodePlanTIDCodecBinary) Encode(value interface{}, buf []byte) (newBuf []
type encodePlanTIDCodecText struct{} type encodePlanTIDCodecText struct{}
func (encodePlanTIDCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTIDCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
tid, err := value.(TIDValuer).TIDValue() tid, err := value.(TIDValuer).TIDValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -130,7 +130,7 @@ func (encodePlanTIDCodecText) Encode(value interface{}, buf []byte) (newBuf []by
return buf, nil return buf, nil
} }
func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -152,7 +152,7 @@ func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) S
type scanPlanBinaryTIDToTIDScanner struct{} type scanPlanBinaryTIDToTIDScanner struct{}
func (scanPlanBinaryTIDToTIDScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryTIDToTIDScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TIDScanner) scanner := (dst).(TIDScanner)
if src == nil { if src == nil {
@@ -172,7 +172,7 @@ func (scanPlanBinaryTIDToTIDScanner) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryTIDToTextScanner struct{} type scanPlanBinaryTIDToTextScanner struct{}
func (scanPlanBinaryTIDToTextScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryTIDToTextScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TextScanner) scanner := (dst).(TextScanner)
if src == nil { if src == nil {
@@ -194,7 +194,7 @@ func (scanPlanBinaryTIDToTextScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToTIDScanner struct{} type scanPlanTextAnyToTIDScanner struct{}
func (scanPlanTextAnyToTIDScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToTIDScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TIDScanner) scanner := (dst).(TIDScanner)
if src == nil { if src == nil {
@@ -227,7 +227,7 @@ func (c TIDCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src [
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c TIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c TIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+8 -8
View File
@@ -37,7 +37,7 @@ func (t Time) TimeValue() (Time, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (t *Time) Scan(src interface{}) error { func (t *Time) Scan(src any) error {
if src == nil { if src == nil {
*t = Time{} *t = Time{}
return nil return nil
@@ -74,7 +74,7 @@ func (TimeCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (TimeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (TimeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(TimeValuer); !ok { if _, ok := value.(TimeValuer); !ok {
return nil return nil
} }
@@ -91,7 +91,7 @@ func (TimeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanTimeCodecBinary struct{} type encodePlanTimeCodecBinary struct{}
func (encodePlanTimeCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTimeCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
t, err := value.(TimeValuer).TimeValue() t, err := value.(TimeValuer).TimeValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -106,7 +106,7 @@ func (encodePlanTimeCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
type encodePlanTimeCodecText struct{} type encodePlanTimeCodecText struct{}
func (encodePlanTimeCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTimeCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
t, err := value.(TimeValuer).TimeValue() t, err := value.(TimeValuer).TimeValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -129,7 +129,7 @@ func (encodePlanTimeCodecText) Encode(value interface{}, buf []byte) (newBuf []b
return append(buf, s...), nil return append(buf, s...), nil
} }
func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -149,7 +149,7 @@ func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryTimeToTimeScanner struct{} type scanPlanBinaryTimeToTimeScanner struct{}
func (scanPlanBinaryTimeToTimeScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryTimeToTimeScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimeScanner) scanner := (dst).(TimeScanner)
if src == nil { if src == nil {
@@ -167,7 +167,7 @@ func (scanPlanBinaryTimeToTimeScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToTimeScanner struct{} type scanPlanTextAnyToTimeScanner struct{}
func (scanPlanTextAnyToTimeScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToTimeScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimeScanner) scanner := (dst).(TimeScanner)
if src == nil { if src == nil {
@@ -219,7 +219,7 @@ func (c TimeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return codecDecodeToTextFormat(c, m, oid, format, src) return codecDecodeToTextFormat(c, m, oid, format, src)
} }
func (c TimeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c TimeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+8 -8
View File
@@ -37,7 +37,7 @@ func (ts Timestamp) TimestampValue() (Timestamp, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (ts *Timestamp) Scan(src interface{}) error { func (ts *Timestamp) Scan(src any) error {
if src == nil { if src == nil {
*ts = Timestamp{} *ts = Timestamp{}
return nil return nil
@@ -76,7 +76,7 @@ func (TimestampCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (TimestampCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (TimestampCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(TimestampValuer); !ok { if _, ok := value.(TimestampValuer); !ok {
return nil return nil
} }
@@ -93,7 +93,7 @@ func (TimestampCodec) PlanEncode(m *Map, oid uint32, format int16, value interfa
type encodePlanTimestampCodecBinary struct{} type encodePlanTimestampCodecBinary struct{}
func (encodePlanTimestampCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTimestampCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
ts, err := value.(TimestampValuer).TimestampValue() ts, err := value.(TimestampValuer).TimestampValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -122,7 +122,7 @@ func (encodePlanTimestampCodecBinary) Encode(value interface{}, buf []byte) (new
type encodePlanTimestampCodecText struct{} type encodePlanTimestampCodecText struct{}
func (encodePlanTimestampCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTimestampCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
ts, err := value.(TimestampValuer).TimestampValue() ts, err := value.(TimestampValuer).TimestampValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -170,7 +170,7 @@ func discardTimeZone(t time.Time) time.Time {
return t return t
} }
func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -190,7 +190,7 @@ func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target interfac
type scanPlanBinaryTimestampToTimestampScanner struct{} type scanPlanBinaryTimestampToTimestampScanner struct{}
func (scanPlanBinaryTimestampToTimestampScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryTimestampToTimestampScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimestampScanner) scanner := (dst).(TimestampScanner)
if src == nil { if src == nil {
@@ -222,7 +222,7 @@ func (scanPlanBinaryTimestampToTimestampScanner) Scan(src []byte, dst interface{
type scanPlanTextTimestampToTimestampScanner struct{} type scanPlanTextTimestampToTimestampScanner struct{}
func (scanPlanTextTimestampToTimestampScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextTimestampToTimestampScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimestampScanner) scanner := (dst).(TimestampScanner)
if src == nil { if src == nil {
@@ -276,7 +276,7 @@ func (c TimestampCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16,
return ts.Time, nil return ts.Time, nil
} }
func (c TimestampCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c TimestampCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+8 -8
View File
@@ -46,7 +46,7 @@ func (tstz Timestamptz) TimestamptzValue() (Timestamptz, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (tstz *Timestamptz) Scan(src interface{}) error { func (tstz *Timestamptz) Scan(src any) error {
if src == nil { if src == nil {
*tstz = Timestamptz{} *tstz = Timestamptz{}
return nil return nil
@@ -134,7 +134,7 @@ func (TimestamptzCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (TimestamptzCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (TimestamptzCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(TimestamptzValuer); !ok { if _, ok := value.(TimestamptzValuer); !ok {
return nil return nil
} }
@@ -151,7 +151,7 @@ func (TimestamptzCodec) PlanEncode(m *Map, oid uint32, format int16, value inter
type encodePlanTimestamptzCodecBinary struct{} type encodePlanTimestamptzCodecBinary struct{}
func (encodePlanTimestamptzCodecBinary) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTimestamptzCodecBinary) Encode(value any, buf []byte) (newBuf []byte, err error) {
ts, err := value.(TimestamptzValuer).TimestamptzValue() ts, err := value.(TimestamptzValuer).TimestamptzValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -179,7 +179,7 @@ func (encodePlanTimestamptzCodecBinary) Encode(value interface{}, buf []byte) (n
type encodePlanTimestamptzCodecText struct{} type encodePlanTimestamptzCodecText struct{}
func (encodePlanTimestamptzCodecText) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanTimestamptzCodecText) Encode(value any, buf []byte) (newBuf []byte, err error) {
ts, err := value.(TimestamptzValuer).TimestamptzValue() ts, err := value.(TimestamptzValuer).TimestamptzValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -220,7 +220,7 @@ func (encodePlanTimestamptzCodecText) Encode(value interface{}, buf []byte) (new
return buf, nil return buf, nil
} }
func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -240,7 +240,7 @@ func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target interf
type scanPlanBinaryTimestamptzToTimestamptzScanner struct{} type scanPlanBinaryTimestamptzToTimestamptzScanner struct{}
func (scanPlanBinaryTimestamptzToTimestamptzScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryTimestamptzToTimestamptzScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimestamptzScanner) scanner := (dst).(TimestamptzScanner)
if src == nil { if src == nil {
@@ -272,7 +272,7 @@ func (scanPlanBinaryTimestamptzToTimestamptzScanner) Scan(src []byte, dst interf
type scanPlanTextTimestamptzToTimestamptzScanner struct{} type scanPlanTextTimestamptzToTimestamptzScanner struct{}
func (scanPlanTextTimestamptzToTimestamptzScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextTimestamptzToTimestamptzScanner) Scan(src []byte, dst any) error {
scanner := (dst).(TimestamptzScanner) scanner := (dst).(TimestamptzScanner)
if src == nil { if src == nil {
@@ -336,7 +336,7 @@ func (c TimestamptzCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int1
return tstz.Time, nil return tstz.Time, nil
} }
func (c TimestamptzCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c TimestamptzCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+13 -13
View File
@@ -34,7 +34,7 @@ func (n Uint32) Uint32Value() (Uint32, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Uint32) Scan(src interface{}) error { func (dst *Uint32) Scan(src any) error {
if src == nil { if src == nil {
*dst = Uint32{} *dst = Uint32{}
return nil return nil
@@ -85,7 +85,7 @@ func (Uint32Codec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (Uint32Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (Uint32Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch value.(type) { switch value.(type) {
@@ -110,14 +110,14 @@ func (Uint32Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{
type encodePlanUint32CodecBinaryUint32 struct{} type encodePlanUint32CodecBinaryUint32 struct{}
func (encodePlanUint32CodecBinaryUint32) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUint32CodecBinaryUint32) Encode(value any, buf []byte) (newBuf []byte, err error) {
v := value.(uint32) v := value.(uint32)
return pgio.AppendUint32(buf, v), nil return pgio.AppendUint32(buf, v), nil
} }
type encodePlanUint32CodecBinaryUint32Valuer struct{} type encodePlanUint32CodecBinaryUint32Valuer struct{}
func (encodePlanUint32CodecBinaryUint32Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUint32CodecBinaryUint32Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
v, err := value.(Uint32Valuer).Uint32Value() v, err := value.(Uint32Valuer).Uint32Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -132,7 +132,7 @@ func (encodePlanUint32CodecBinaryUint32Valuer) Encode(value interface{}, buf []b
type encodePlanUint32CodecBinaryInt64Valuer struct{} type encodePlanUint32CodecBinaryInt64Valuer struct{}
func (encodePlanUint32CodecBinaryInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUint32CodecBinaryInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
v, err := value.(Int64Valuer).Int64Value() v, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -154,14 +154,14 @@ func (encodePlanUint32CodecBinaryInt64Valuer) Encode(value interface{}, buf []by
type encodePlanUint32CodecTextUint32 struct{} type encodePlanUint32CodecTextUint32 struct{}
func (encodePlanUint32CodecTextUint32) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUint32CodecTextUint32) Encode(value any, buf []byte) (newBuf []byte, err error) {
v := value.(uint32) v := value.(uint32)
return append(buf, strconv.FormatUint(uint64(v), 10)...), nil return append(buf, strconv.FormatUint(uint64(v), 10)...), nil
} }
type encodePlanUint32CodecTextUint32Valuer struct{} type encodePlanUint32CodecTextUint32Valuer struct{}
func (encodePlanUint32CodecTextUint32Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUint32CodecTextUint32Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
v, err := value.(Uint32Valuer).Uint32Value() v, err := value.(Uint32Valuer).Uint32Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -176,7 +176,7 @@ func (encodePlanUint32CodecTextUint32Valuer) Encode(value interface{}, buf []byt
type encodePlanUint32CodecTextInt64Valuer struct{} type encodePlanUint32CodecTextInt64Valuer struct{}
func (encodePlanUint32CodecTextInt64Valuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUint32CodecTextInt64Valuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
v, err := value.(Int64Valuer).Int64Value() v, err := value.(Int64Valuer).Int64Value()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -196,7 +196,7 @@ func (encodePlanUint32CodecTextInt64Valuer) Encode(value interface{}, buf []byte
return append(buf, strconv.FormatInt(v.Int64, 10)...), nil return append(buf, strconv.FormatInt(v.Int64, 10)...), nil
} }
func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
@@ -231,7 +231,7 @@ func (c Uint32Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, sr
return int64(n), nil return int64(n), nil
} }
func (c Uint32Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c Uint32Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
@@ -246,7 +246,7 @@ func (c Uint32Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (
type scanPlanBinaryUint32ToUint32 struct{} type scanPlanBinaryUint32ToUint32 struct{}
func (scanPlanBinaryUint32ToUint32) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryUint32ToUint32) Scan(src []byte, dst any) error {
if src == nil { if src == nil {
return fmt.Errorf("cannot scan null into %T", dst) return fmt.Errorf("cannot scan null into %T", dst)
} }
@@ -263,7 +263,7 @@ func (scanPlanBinaryUint32ToUint32) Scan(src []byte, dst interface{}) error {
type scanPlanBinaryUint32ToUint32Scanner struct{} type scanPlanBinaryUint32ToUint32Scanner struct{}
func (scanPlanBinaryUint32ToUint32Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryUint32ToUint32Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Uint32Scanner) s, ok := (dst).(Uint32Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
@@ -284,7 +284,7 @@ func (scanPlanBinaryUint32ToUint32Scanner) Scan(src []byte, dst interface{}) err
type scanPlanTextAnyToUint32Scanner struct{} type scanPlanTextAnyToUint32Scanner struct{}
func (scanPlanTextAnyToUint32Scanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUint32Scanner) Scan(src []byte, dst any) error {
s, ok := (dst).(Uint32Scanner) s, ok := (dst).(Uint32Scanner)
if !ok { if !ok {
return ErrScanTargetTypeChanged return ErrScanTargetTypeChanged
+8 -8
View File
@@ -56,7 +56,7 @@ func encodeUUID(src [16]byte) string {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *UUID) Scan(src interface{}) error { func (dst *UUID) Scan(src any) error {
if src == nil { if src == nil {
*dst = UUID{} *dst = UUID{}
return nil return nil
@@ -122,7 +122,7 @@ func (UUIDCodec) PreferredFormat() int16 {
return BinaryFormatCode return BinaryFormatCode
} }
func (UUIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan { func (UUIDCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
if _, ok := value.(UUIDValuer); !ok { if _, ok := value.(UUIDValuer); !ok {
return nil return nil
} }
@@ -139,7 +139,7 @@ func (UUIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{})
type encodePlanUUIDCodecBinaryUUIDValuer struct{} type encodePlanUUIDCodecBinaryUUIDValuer struct{}
func (encodePlanUUIDCodecBinaryUUIDValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUUIDCodecBinaryUUIDValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
uuid, err := value.(UUIDValuer).UUIDValue() uuid, err := value.(UUIDValuer).UUIDValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -154,7 +154,7 @@ func (encodePlanUUIDCodecBinaryUUIDValuer) Encode(value interface{}, buf []byte)
type encodePlanUUIDCodecTextUUIDValuer struct{} type encodePlanUUIDCodecTextUUIDValuer struct{}
func (encodePlanUUIDCodecTextUUIDValuer) Encode(value interface{}, buf []byte) (newBuf []byte, err error) { func (encodePlanUUIDCodecTextUUIDValuer) Encode(value any, buf []byte) (newBuf []byte, err error) {
uuid, err := value.(UUIDValuer).UUIDValue() uuid, err := value.(UUIDValuer).UUIDValue()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -167,7 +167,7 @@ func (encodePlanUUIDCodecTextUUIDValuer) Encode(value interface{}, buf []byte) (
return append(buf, encodeUUID(uuid.Bytes)...), nil return append(buf, encodeUUID(uuid.Bytes)...), nil
} }
func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan { func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format { switch format {
case BinaryFormatCode: case BinaryFormatCode:
switch target.(type) { switch target.(type) {
@@ -186,7 +186,7 @@ func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{})
type scanPlanBinaryUUIDToUUIDScanner struct{} type scanPlanBinaryUUIDToUUIDScanner struct{}
func (scanPlanBinaryUUIDToUUIDScanner) Scan(src []byte, dst interface{}) error { func (scanPlanBinaryUUIDToUUIDScanner) Scan(src []byte, dst any) error {
scanner := (dst).(UUIDScanner) scanner := (dst).(UUIDScanner)
if src == nil { if src == nil {
@@ -205,7 +205,7 @@ func (scanPlanBinaryUUIDToUUIDScanner) Scan(src []byte, dst interface{}) error {
type scanPlanTextAnyToUUIDScanner struct{} type scanPlanTextAnyToUUIDScanner struct{}
func (scanPlanTextAnyToUUIDScanner) Scan(src []byte, dst interface{}) error { func (scanPlanTextAnyToUUIDScanner) Scan(src []byte, dst any) error {
scanner := (dst).(UUIDScanner) scanner := (dst).(UUIDScanner)
if src == nil { if src == nil {
@@ -234,7 +234,7 @@ func (c UUIDCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src
return encodeUUID(uuid.Bytes), nil return encodeUUID(uuid.Bytes), nil
} }
func (c UUIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) { func (c UUIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil { if src == nil {
return nil, nil return nil, nil
} }
+1 -1
View File
@@ -30,7 +30,7 @@ func (f Float8) Float64Value() (pgtype.Float8, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (f *Float8) Scan(src interface{}) error { func (f *Float8) Scan(src any) error {
if src == nil { if src == nil {
*f = 0 *f = 0
return nil return nil
+3 -3
View File
@@ -8,8 +8,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEq(a interface{}) func(interface{}) bool { func isExpectedEq(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
return a == v return a == v
} }
} }
@@ -28,7 +28,7 @@ func TestFloat8Transcode(t *testing.T) {
}, },
{ {
(zeronull.Float8)(0), (zeronull.Float8)(0),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+3 -3
View File
@@ -32,7 +32,7 @@ func (dst *Int2) ScanInt64(n int64, valid bool) error {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int2) Scan(src interface{}) error { func (dst *Int2) Scan(src any) error {
if src == nil { if src == nil {
*dst = 0 *dst = 0
return nil return nil
@@ -80,7 +80,7 @@ func (dst *Int4) ScanInt64(n int64, valid bool) error {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int4) Scan(src interface{}) error { func (dst *Int4) Scan(src any) error {
if src == nil { if src == nil {
*dst = 0 *dst = 0
return nil return nil
@@ -128,7 +128,7 @@ func (dst *Int8) ScanInt64(n int64, valid bool) error {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int8) Scan(src interface{}) error { func (dst *Int8) Scan(src any) error {
if src == nil { if src == nil {
*dst = 0 *dst = 0
return nil return nil
+1 -1
View File
@@ -33,7 +33,7 @@ func (dst *Int<%= pg_byte_size %>) ScanInt64(n int64, valid bool) error {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Int<%= pg_byte_size %>) Scan(src interface{}) error { func (dst *Int<%= pg_byte_size %>) Scan(src any) error {
if src == nil { if src == nil {
*dst = 0 *dst = 0
return nil return nil
+3 -3
View File
@@ -23,7 +23,7 @@ func TestInt2Transcode(t *testing.T) {
}, },
{ {
(zeronull.Int2)(0), (zeronull.Int2)(0),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
@@ -43,7 +43,7 @@ func TestInt4Transcode(t *testing.T) {
}, },
{ {
(zeronull.Int4)(0), (zeronull.Int4)(0),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
@@ -63,7 +63,7 @@ func TestInt8Transcode(t *testing.T) {
}, },
{ {
(zeronull.Int8)(0), (zeronull.Int8)(0),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+1 -1
View File
@@ -23,7 +23,7 @@ func TestInt<%= pg_byte_size %>Transcode(t *testing.T) {
}, },
{ {
(zeronull.Int<%= pg_byte_size %>)(0), (zeronull.Int<%= pg_byte_size %>)(0),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+1 -1
View File
@@ -23,7 +23,7 @@ func (dst *Text) ScanText(v pgtype.Text) error {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (dst *Text) Scan(src interface{}) error { func (dst *Text) Scan(src any) error {
if src == nil { if src == nil {
*dst = "" *dst = ""
return nil return nil
+1 -1
View File
@@ -22,7 +22,7 @@ func TestTextTranscode(t *testing.T) {
}, },
{ {
(zeronull.Text)(""), (zeronull.Text)(""),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+1 -1
View File
@@ -40,7 +40,7 @@ func (ts Timestamp) TimestampValue() (pgtype.Timestamp, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (ts *Timestamp) Scan(src interface{}) error { func (ts *Timestamp) Scan(src any) error {
if src == nil { if src == nil {
*ts = Timestamp{} *ts = Timestamp{}
return nil return nil
+3 -3
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqTimestamp(a interface{}) func(interface{}) bool { func isExpectedEqTimestamp(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
at := time.Time(a.(zeronull.Timestamp)) at := time.Time(a.(zeronull.Timestamp))
vt := time.Time(v.(zeronull.Timestamp)) vt := time.Time(v.(zeronull.Timestamp))
@@ -32,7 +32,7 @@ func TestTimestampTranscode(t *testing.T) {
}, },
{ {
(zeronull.Timestamp)(time.Time{}), (zeronull.Timestamp)(time.Time{}),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+1 -1
View File
@@ -40,7 +40,7 @@ func (ts Timestamptz) TimestamptzValue() (pgtype.Timestamptz, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (ts *Timestamptz) Scan(src interface{}) error { func (ts *Timestamptz) Scan(src any) error {
if src == nil { if src == nil {
*ts = Timestamptz{} *ts = Timestamptz{}
return nil return nil
+3 -3
View File
@@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v5/pgxtest" "github.com/jackc/pgx/v5/pgxtest"
) )
func isExpectedEqTimestamptz(a interface{}) func(interface{}) bool { func isExpectedEqTimestamptz(a any) func(any) bool {
return func(v interface{}) bool { return func(v any) bool {
at := time.Time(a.(zeronull.Timestamptz)) at := time.Time(a.(zeronull.Timestamptz))
vt := time.Time(v.(zeronull.Timestamptz)) vt := time.Time(v.(zeronull.Timestamptz))
@@ -32,7 +32,7 @@ func TestTimestamptzTranscode(t *testing.T) {
}, },
{ {
(zeronull.Timestamptz)(time.Time{}), (zeronull.Timestamptz)(time.Time{}),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+1 -1
View File
@@ -30,7 +30,7 @@ func (u UUID) UUIDValue() (pgtype.UUID, error) {
} }
// Scan implements the database/sql Scanner interface. // Scan implements the database/sql Scanner interface.
func (u *UUID) Scan(src interface{}) error { func (u *UUID) Scan(src any) error {
if src == nil { if src == nil {
*u = UUID{} *u = UUID{}
return nil return nil
+1 -1
View File
@@ -22,7 +22,7 @@ func TestUUIDTranscode(t *testing.T) {
}, },
{ {
(zeronull.UUID)([16]byte{}), (zeronull.UUID)([16]byte{}),
new(interface{}), new(any),
isExpectedEq(nil), isExpectedEq(nil),
}, },
}) })
+2 -2
View File
@@ -17,7 +17,7 @@ func (br errBatchResults) Query() (pgx.Rows, error) {
return errRows{err: br.err}, br.err return errRows{err: br.err}, br.err
} }
func (br errBatchResults) QueryFunc(scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) { func (br errBatchResults) QueryFunc(scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return pgconn.CommandTag{}, br.err return pgconn.CommandTag{}, br.err
} }
@@ -42,7 +42,7 @@ func (br *poolBatchResults) Query() (pgx.Rows, error) {
return br.br.Query() return br.br.Query()
} }
func (br *poolBatchResults) QueryFunc(scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) { func (br *poolBatchResults) QueryFunc(scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return br.br.QueryFunc(scans, f) return br.br.QueryFunc(scans, f)
} }
+5 -5
View File
@@ -21,7 +21,7 @@ func waitForReleaseToComplete() {
} }
type execer interface { type execer interface {
Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
} }
func testExec(t *testing.T, db execer) { func testExec(t *testing.T, db execer) {
@@ -31,7 +31,7 @@ func testExec(t *testing.T, db execer) {
} }
type queryer interface { type queryer interface {
Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
} }
func testQuery(t *testing.T, db queryer) { func testQuery(t *testing.T, db queryer) {
@@ -53,7 +53,7 @@ func testQuery(t *testing.T, db queryer) {
} }
type queryRower interface { type queryRower interface {
QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
} }
func testQueryRow(t *testing.T, db queryRower) { func testQueryRow(t *testing.T, db queryRower) {
@@ -103,7 +103,7 @@ func testCopyFrom(t *testing.T, db interface {
tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local) tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local)
inputRows := [][]interface{}{ inputRows := [][]any{
{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime}, {int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime},
{nil, nil, nil, nil, nil, nil, nil}, {nil, nil, nil, nil, nil, nil, nil},
} }
@@ -115,7 +115,7 @@ func testCopyFrom(t *testing.T, db interface {
rows, err := db.Query(context.Background(), "select * from foo") rows, err := db.Query(context.Background(), "select * from foo")
assert.NoError(t, err) assert.NoError(t, err)
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
+4 -4
View File
@@ -46,19 +46,19 @@ func (c *Conn) Release() {
}() }()
} }
func (c *Conn) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) { func (c *Conn) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) {
return c.Conn().Exec(ctx, sql, arguments...) return c.Conn().Exec(ctx, sql, arguments...)
} }
func (c *Conn) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) { func (c *Conn) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
return c.Conn().Query(ctx, sql, args...) return c.Conn().Query(ctx, sql, args...)
} }
func (c *Conn) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row { func (c *Conn) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row {
return c.Conn().QueryRow(ctx, sql, args...) 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) { func (c *Conn) QueryFunc(ctx context.Context, sql string, args []any, scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return c.Conn().QueryFunc(ctx, sql, args, scans, f) return c.Conn().QueryFunc(ctx, sql, args, scans, f)
} }
+6 -6
View File
@@ -177,7 +177,7 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
} }
p.p = puddle.NewPool( p.p = puddle.NewPool(
func(ctx context.Context) (interface{}, error) { func(ctx context.Context) (any, error) {
connConfig := p.config.ConnConfig connConfig := p.config.ConnConfig
if p.beforeConnect != nil { if p.beforeConnect != nil {
@@ -209,7 +209,7 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
return cr, nil return cr, nil
}, },
func(value interface{}) { func(value any) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
conn := value.(*connResource).conn conn := value.(*connResource).conn
conn.Close(ctx) conn.Close(ctx)
@@ -467,7 +467,7 @@ func (p *Pool) Stat() *Stat {
// SQL can be either a prepared statement name or an SQL string. // SQL can be either a prepared statement name or an SQL string.
// Arguments should be referenced positionally from the SQL string as $1, $2, etc. // Arguments should be referenced positionally from the SQL string as $1, $2, etc.
// The acquired connection is returned to the pool when the Exec function returns. // The acquired connection is returned to the pool when the Exec function returns.
func (p *Pool) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) { func (p *Pool) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) {
c, err := p.Acquire(ctx) c, err := p.Acquire(ctx)
if err != nil { if err != nil {
return pgconn.CommandTag{}, err return pgconn.CommandTag{}, err
@@ -487,7 +487,7 @@ func (p *Pool) Exec(ctx context.Context, sql string, arguments ...interface{}) (
// For extra control over how the query is executed, the types QuerySimpleProtocol, QueryResultFormats, and // For extra control over how the query is executed, the types QuerySimpleProtocol, QueryResultFormats, and
// QueryResultFormatsByOID may be used as the first args to control exactly how the query is executed. This is rarely // QueryResultFormatsByOID may be used as the first args to control exactly how the query is executed. This is rarely
// needed. See the documentation for those types for details. // needed. See the documentation for those types for details.
func (p *Pool) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) { func (p *Pool) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
c, err := p.Acquire(ctx) c, err := p.Acquire(ctx)
if err != nil { if err != nil {
return errRows{err: err}, err return errRows{err: err}, err
@@ -514,7 +514,7 @@ func (p *Pool) Query(ctx context.Context, sql string, args ...interface{}) (pgx.
// For extra control over how the query is executed, the types QuerySimpleProtocol, QueryResultFormats, and // For extra control over how the query is executed, the types QuerySimpleProtocol, QueryResultFormats, and
// QueryResultFormatsByOID may be used as the first args to control exactly how the query is executed. This is rarely // QueryResultFormatsByOID may be used as the first args to control exactly how the query is executed. This is rarely
// needed. See the documentation for those types for details. // needed. See the documentation for those types for details.
func (p *Pool) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row { func (p *Pool) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row {
c, err := p.Acquire(ctx) c, err := p.Acquire(ctx)
if err != nil { if err != nil {
return errRow{err: err} return errRow{err: err}
@@ -524,7 +524,7 @@ func (p *Pool) QueryRow(ctx context.Context, sql string, args ...interface{}) pg
return c.getPoolRow(row) 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) { func (p *Pool) QueryFunc(ctx context.Context, sql string, args []any, scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
c, err := p.Acquire(ctx) c, err := p.Acquire(ctx)
if err != nil { if err != nil {
return pgconn.CommandTag{}, err return pgconn.CommandTag{}, err
+2 -2
View File
@@ -514,7 +514,7 @@ func TestPoolCopyFrom(t *testing.T) {
tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local) tzedTime := time.Date(2010, 2, 3, 4, 5, 6, 0, time.Local)
inputRows := [][]interface{}{ inputRows := [][]any{
{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime}, {int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime},
{nil, nil, nil, nil, nil, nil, nil}, {nil, nil, nil, nil, nil, nil, nil},
} }
@@ -526,7 +526,7 @@ func TestPoolCopyFrom(t *testing.T) {
rows, err := pool.Query(ctx, "select * from poolcopyfromtest") rows, err := pool.Query(ctx, "select * from poolcopyfromtest")
assert.NoError(t, err) assert.NoError(t, err)
var outputRows [][]interface{} var outputRows [][]any
for rows.Next() { for rows.Next() {
row, err := rows.Values() row, err := rows.Values()
if err != nil { if err != nil {
+6 -6
View File
@@ -15,15 +15,15 @@ func (e errRows) Err() error { return e.err }
func (errRows) CommandTag() pgconn.CommandTag { return pgconn.CommandTag{} } func (errRows) CommandTag() pgconn.CommandTag { return pgconn.CommandTag{} }
func (errRows) FieldDescriptions() []pgproto3.FieldDescription { return nil } func (errRows) FieldDescriptions() []pgproto3.FieldDescription { return nil }
func (errRows) Next() bool { return false } func (errRows) Next() bool { return false }
func (e errRows) Scan(dest ...interface{}) error { return e.err } func (e errRows) Scan(dest ...any) error { return e.err }
func (e errRows) Values() ([]interface{}, error) { return nil, e.err } func (e errRows) Values() ([]any, error) { return nil, e.err }
func (e errRows) RawValues() [][]byte { return nil } func (e errRows) RawValues() [][]byte { return nil }
type errRow struct { type errRow struct {
err error err error
} }
func (e errRow) Scan(dest ...interface{}) error { return e.err } func (e errRow) Scan(dest ...any) error { return e.err }
type poolRows struct { type poolRows struct {
r pgx.Rows r pgx.Rows
@@ -66,7 +66,7 @@ func (rows *poolRows) Next() bool {
return n return n
} }
func (rows *poolRows) Scan(dest ...interface{}) error { func (rows *poolRows) Scan(dest ...any) error {
err := rows.r.Scan(dest...) err := rows.r.Scan(dest...)
if err != nil { if err != nil {
rows.Close() rows.Close()
@@ -74,7 +74,7 @@ func (rows *poolRows) Scan(dest ...interface{}) error {
return err return err
} }
func (rows *poolRows) Values() ([]interface{}, error) { func (rows *poolRows) Values() ([]any, error) {
values, err := rows.r.Values() values, err := rows.r.Values()
if err != nil { if err != nil {
rows.Close() rows.Close()
@@ -92,7 +92,7 @@ type poolRow struct {
err error err error
} }
func (row *poolRow) Scan(dest ...interface{}) error { func (row *poolRow) Scan(dest ...any) error {
if row.err != nil { if row.err != nil {
return row.err return row.err
} }
+4 -4
View File
@@ -69,19 +69,19 @@ func (tx *Tx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementD
return tx.t.Prepare(ctx, name, sql) return tx.t.Prepare(ctx, name, sql)
} }
func (tx *Tx) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) { func (tx *Tx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) {
return tx.t.Exec(ctx, sql, arguments...) return tx.t.Exec(ctx, sql, arguments...)
} }
func (tx *Tx) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error) { func (tx *Tx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
return tx.t.Query(ctx, sql, args...) return tx.t.Query(ctx, sql, args...)
} }
func (tx *Tx) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row { func (tx *Tx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row {
return tx.t.QueryRow(ctx, sql, args...) 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) { func (tx *Tx) QueryFunc(ctx context.Context, sql string, args []any, scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) {
return tx.t.QueryFunc(ctx, sql, args, scans, f) return tx.t.QueryFunc(ctx, sql, args, scans, f)
} }
+3 -3
View File
@@ -101,9 +101,9 @@ func RunWithQueryExecModes(ctx context.Context, t *testing.T, ctr ConnTestRunner
} }
type ValueRoundTripTest struct { type ValueRoundTripTest struct {
Param interface{} Param any
Result interface{} Result any
Test func(interface{}) bool Test func(any) bool
} }
func RunValueRoundTripTests( func RunValueRoundTripTests(
+39 -39
View File
@@ -109,7 +109,7 @@ func TestConnQueryScanWithManyColumns(t *testing.T) {
defer rows.Close() defer rows.Close()
for rows.Next() { for rows.Next() {
destPtrs := make([]interface{}, columnCount) destPtrs := make([]any, columnCount)
for i := range destPtrs { for i := range destPtrs {
destPtrs[i] = &dest[i] destPtrs[i] = &dest[i]
} }
@@ -597,18 +597,18 @@ func TestQueryRowCoreTypes(t *testing.T) {
tests := []struct { tests := []struct {
sql string sql string
queryArgs []interface{} queryArgs []any
scanArgs []interface{} scanArgs []any
expected allTypes expected allTypes
}{ }{
{"select $1::text", []interface{}{"Jack"}, []interface{}{&actual.s}, allTypes{s: "Jack"}}, {"select $1::text", []any{"Jack"}, []any{&actual.s}, allTypes{s: "Jack"}},
{"select $1::float4", []interface{}{float32(1.23)}, []interface{}{&actual.f32}, allTypes{f32: 1.23}}, {"select $1::float4", []any{float32(1.23)}, []any{&actual.f32}, allTypes{f32: 1.23}},
{"select $1::float8", []interface{}{float64(1.23)}, []interface{}{&actual.f64}, allTypes{f64: 1.23}}, {"select $1::float8", []any{float64(1.23)}, []any{&actual.f64}, allTypes{f64: 1.23}},
{"select $1::bool", []interface{}{true}, []interface{}{&actual.b}, allTypes{b: true}}, {"select $1::bool", []any{true}, []any{&actual.b}, allTypes{b: true}},
{"select $1::timestamptz", []interface{}{time.Unix(123, 5000)}, []interface{}{&actual.t}, allTypes{t: time.Unix(123, 5000)}}, {"select $1::timestamptz", []any{time.Unix(123, 5000)}, []any{&actual.t}, allTypes{t: time.Unix(123, 5000)}},
{"select $1::timestamp", []interface{}{time.Date(2010, 1, 2, 3, 4, 5, 0, time.UTC)}, []interface{}{&actual.t}, allTypes{t: time.Date(2010, 1, 2, 3, 4, 5, 0, time.UTC)}}, {"select $1::timestamp", []any{time.Date(2010, 1, 2, 3, 4, 5, 0, time.UTC)}, []any{&actual.t}, allTypes{t: time.Date(2010, 1, 2, 3, 4, 5, 0, time.UTC)}},
{"select $1::date", []interface{}{time.Date(1987, 1, 2, 0, 0, 0, 0, time.UTC)}, []interface{}{&actual.t}, allTypes{t: time.Date(1987, 1, 2, 0, 0, 0, 0, time.UTC)}}, {"select $1::date", []any{time.Date(1987, 1, 2, 0, 0, 0, 0, time.UTC)}, []any{&actual.t}, allTypes{t: time.Date(1987, 1, 2, 0, 0, 0, 0, time.UTC)}},
{"select $1::oid", []interface{}{uint32(42)}, []interface{}{&actual.oid}, allTypes{oid: 42}}, {"select $1::oid", []any{uint32(42)}, []any{&actual.oid}, allTypes{oid: 42}},
} }
for i, tt := range tests { for i, tt := range tests {
@@ -658,8 +658,8 @@ func TestQueryRowCoreIntegerEncoding(t *testing.T) {
successfulEncodeTests := []struct { successfulEncodeTests := []struct {
sql string sql string
queryArg interface{} queryArg any
scanArg interface{} scanArg any
expected allTypes expected allTypes
}{ }{
// Check any integer type where value is within int2 range can be encoded // Check any integer type where value is within int2 range can be encoded
@@ -717,7 +717,7 @@ func TestQueryRowCoreIntegerEncoding(t *testing.T) {
failedEncodeTests := []struct { failedEncodeTests := []struct {
sql string sql string
queryArg interface{} queryArg any
}{ }{
// Check any integer type where value is outside pg:int2 range cannot be encoded // Check any integer type where value is outside pg:int2 range cannot be encoded
{"select $1::int2", int(32769)}, {"select $1::int2", int(32769)},
@@ -773,7 +773,7 @@ func TestQueryRowCoreIntegerDecoding(t *testing.T) {
successfulDecodeTests := []struct { successfulDecodeTests := []struct {
sql string sql string
scanArg interface{} scanArg any
expected allTypes expected allTypes
}{ }{
// Check any integer type where value is within Go:int range can be decoded // Check any integer type where value is within Go:int range can be decoded
@@ -860,7 +860,7 @@ func TestQueryRowCoreIntegerDecoding(t *testing.T) {
failedDecodeTests := []struct { failedDecodeTests := []struct {
sql string sql string
scanArg interface{} scanArg any
}{ }{
// Check any integer type where value is outside Go:int8 range cannot be decoded // Check any integer type where value is outside Go:int8 range cannot be decoded
{"select 128::int2", &actual.i8}, {"select 128::int2", &actual.i8},
@@ -932,7 +932,7 @@ func TestQueryRowCoreByteSlice(t *testing.T) {
tests := []struct { tests := []struct {
sql string sql string
queryArg interface{} queryArg any
expected []byte expected []byte
}{ }{
{"select $1::text", "Jack", []byte("Jack")}, {"select $1::text", "Jack", []byte("Jack")},
@@ -977,14 +977,14 @@ func TestQueryRowErrors(t *testing.T) {
tests := []struct { tests := []struct {
sql string sql string
queryArgs []interface{} queryArgs []any
scanArgs []interface{} scanArgs []any
err string err string
}{ }{
{"select $1::badtype", []interface{}{"Jack"}, []interface{}{&actual.i16}, `type "badtype" does not exist`}, {"select $1::badtype", []any{"Jack"}, []any{&actual.i16}, `type "badtype" does not exist`},
{"SYNTAX ERROR", []interface{}{}, []interface{}{&actual.i16}, "SQLSTATE 42601"}, {"SYNTAX ERROR", []any{}, []any{&actual.i16}, "SQLSTATE 42601"},
{"select $1::text", []interface{}{"Jack"}, []interface{}{&actual.i16}, "cannot scan OID 25 in text format into *int16"}, {"select $1::text", []any{"Jack"}, []any{&actual.i16}, "cannot scan OID 25 in text format into *int16"},
{"select $1::point", []interface{}{int(705)}, []interface{}{&actual.s}, "unable to encode 705 into format code 1 for OID 600"}, {"select $1::point", []any{int(705)}, []any{&actual.s}, "unable to encode 705 into format code 1 for OID 600"},
} }
for i, tt := range tests { for i, tt := range tests {
@@ -1868,25 +1868,25 @@ func TestConnQueryFunc(t *testing.T) {
t.Parallel() t.Parallel()
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
var actualResults []interface{} var actualResults []any
var a, b int var a, b int
ct, err := conn.QueryFunc( ct, err := conn.QueryFunc(
context.Background(), context.Background(),
"select n, n * 2 from generate_series(1, $1) n", "select n, n * 2 from generate_series(1, $1) n",
[]interface{}{3}, []any{3},
[]interface{}{&a, &b}, []any{&a, &b},
func(pgx.QueryFuncRow) error { func(pgx.QueryFuncRow) error {
actualResults = append(actualResults, []interface{}{a, b}) actualResults = append(actualResults, []any{a, b})
return nil return nil
}, },
) )
require.NoError(t, err) require.NoError(t, err)
expectedResults := []interface{}{ expectedResults := []any{
[]interface{}{1, 2}, []any{1, 2},
[]interface{}{2, 4}, []any{2, 4},
[]interface{}{3, 6}, []any{3, 6},
} }
require.Equal(t, expectedResults, actualResults) require.Equal(t, expectedResults, actualResults)
require.EqualValues(t, 3, ct.RowsAffected()) require.EqualValues(t, 3, ct.RowsAffected())
@@ -1897,16 +1897,16 @@ func TestConnQueryFuncScanError(t *testing.T) {
t.Parallel() t.Parallel()
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
var actualResults []interface{} var actualResults []any
var a, b int var a, b int
ct, err := conn.QueryFunc( ct, err := conn.QueryFunc(
context.Background(), context.Background(),
"select 'foo', 'bar' from generate_series(1, $1) n", "select 'foo', 'bar' from generate_series(1, $1) n",
[]interface{}{3}, []any{3},
[]interface{}{&a, &b}, []any{&a, &b},
func(pgx.QueryFuncRow) error { func(pgx.QueryFuncRow) error {
actualResults = append(actualResults, []interface{}{a, b}) actualResults = append(actualResults, []any{a, b})
return nil return nil
}, },
) )
@@ -1923,8 +1923,8 @@ func TestConnQueryFuncAbort(t *testing.T) {
ct, err := conn.QueryFunc( ct, err := conn.QueryFunc(
context.Background(), context.Background(),
"select n, n * 2 from generate_series(1, $1) n", "select n, n * 2 from generate_series(1, $1) n",
[]interface{}{3}, []any{3},
[]interface{}{&a, &b}, []any{&a, &b},
func(pgx.QueryFuncRow) error { func(pgx.QueryFuncRow) error {
return errors.New("abort") return errors.New("abort")
}, },
@@ -1945,8 +1945,8 @@ func ExampleConn_QueryFunc() {
_, err = conn.QueryFunc( _, err = conn.QueryFunc(
context.Background(), context.Background(),
"select n, n * 2 from generate_series(1, $1) n", "select n, n * 2 from generate_series(1, $1) n",
[]interface{}{3}, []any{3},
[]interface{}{&a, &b}, []any{&a, &b},
func(pgx.QueryFuncRow) error { func(pgx.QueryFuncRow) error {
fmt.Printf("%v, %v\n", a, b) fmt.Printf("%v, %v\n", a, b)
return nil return nil

Some files were not shown because too many files have changed in this diff Show More