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
+8 -8
View File
@@ -37,7 +37,7 @@
// // handle error from acquiring connection from DB pool
// }
//
// err = conn.Raw(func(driverConn interface{}) error {
// err = conn.Raw(func(driverConn any) error {
// conn := driverConn.(*stdlib.Conn).Conn() // conn is a *pgx.Conn
// // Do pgx specific stuff with conn
// conn.CopyFrom(...)
@@ -413,7 +413,7 @@ func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.Na
return nil, driver.ErrBadConn
}
args := []interface{}{databaseSQLResultFormats}
args := []any{databaseSQLResultFormats}
args = append(args, namedValueToInterface(argsV)...)
rows, err := c.conn.Query(ctx, query, args...)
@@ -746,11 +746,11 @@ func (r *Rows) Next(dest []driver.Value) error {
return nil
}
func valueToInterface(argsV []driver.Value) []interface{} {
args := make([]interface{}, 0, len(argsV))
func valueToInterface(argsV []driver.Value) []any {
args := make([]any, 0, len(argsV))
for _, v := range argsV {
if v != nil {
args = append(args, v.(interface{}))
args = append(args, v.(any))
} else {
args = append(args, nil)
}
@@ -758,11 +758,11 @@ func valueToInterface(argsV []driver.Value) []interface{} {
return args
}
func namedValueToInterface(argsV []driver.NamedValue) []interface{} {
args := make([]interface{}, 0, len(argsV))
func namedValueToInterface(argsV []driver.NamedValue) []any {
args := make([]any, 0, len(argsV))
for _, v := range argsV {
if v.Value != nil {
args = append(args, v.Value.(interface{}))
args = append(args, v.Value.(any))
} else {
args = append(args, nil)
}
+5 -5
View File
@@ -36,7 +36,7 @@ func skipCockroachDB(t testing.TB, db *sql.DB, msg string) {
require.NoError(t, err)
defer conn.Close()
err = conn.Raw(func(driverConn interface{}) error {
err = conn.Raw(func(driverConn any) error {
conn := driverConn.(*stdlib.Conn).Conn()
if conn.PgConn().ParameterStatus("crdb_version") != "" {
t.Skip(msg)
@@ -51,7 +51,7 @@ func skipPostgreSQLVersionLessThan(t testing.TB, db *sql.DB, minVersion int64) {
require.NoError(t, err)
defer conn.Close()
err = conn.Raw(func(driverConn interface{}) error {
err = conn.Raw(func(driverConn any) error {
conn := driverConn.(*stdlib.Conn).Conn()
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
serverVersionStr = regexp.MustCompile(`^[0-9]+`).FindString(serverVersionStr)
@@ -639,7 +639,7 @@ func TestConnRaw(t *testing.T) {
require.NoError(t, err)
var n int
err = conn.Raw(func(driverConn interface{}) error {
err = conn.Raw(func(driverConn any) error {
conn := driverConn.(*stdlib.Conn).Conn()
return conn.QueryRow(context.Background(), "select 42").Scan(&n)
})
@@ -1036,14 +1036,14 @@ func TestScanJSONIntoJSONRawMessage(t *testing.T) {
type testLog struct {
lvl pgx.LogLevel
msg string
data map[string]interface{}
data map[string]any
}
type testLogger struct {
logs []testLog
}
func (l *testLogger) Log(ctx context.Context, lvl pgx.LogLevel, msg string, data map[string]interface{}) {
func (l *testLogger) Log(ctx context.Context, lvl pgx.LogLevel, msg string, data map[string]any) {
l.logs = append(l.logs, testLog{lvl: lvl, msg: msg, data: data})
}