update go version to 1.19

This commit is contained in:
Yasuhiro Matsumoto 2024-01-25 22:36:00 +09:00 committed by mattn
parent 00b02e0ba9
commit c91bca4fb4
21 changed files with 88 additions and 89 deletions

View File

@ -14,7 +14,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
go: ['1.18', '1.19', '1.20'] go: ['1.19', '1.20', '1.21']
fail-fast: false fail-fast: false
env: env:
OS: ${{ matrix.os }} OS: ${{ matrix.os }}
@ -64,7 +64,7 @@ jobs:
strategy: strategy:
matrix: matrix:
go: ['1.18', '1.19', '1.20'] go: ['1.19', '1.20', '1.21']
fail-fast: false fail-fast: false
env: env:
OS: windows-latest OS: windows-latest

View File

@ -10,9 +10,9 @@ import (
"github.com/mattn/go-sqlite3" "github.com/mattn/go-sqlite3"
) )
func createBulkInsertQuery(n int, start int) (query string, args []interface{}) { func createBulkInsertQuery(n int, start int) (query string, args []any) {
values := make([]string, n) values := make([]string, n)
args = make([]interface{}, n*2) args = make([]any, n*2)
pos := 0 pos := 0
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
values[i] = "(?, ?)" values[i] = "(?, ?)"
@ -27,7 +27,7 @@ func createBulkInsertQuery(n int, start int) (query string, args []interface{})
return return
} }
func bulkInsert(db *sql.DB, query string, args []interface{}) (err error) { func bulkInsert(db *sql.DB, query string, args []any) (err error) {
stmt, err := db.Prepare(query) stmt, err := db.Prepare(query)
if err != nil { if err != nil {
return return

View File

@ -93,7 +93,7 @@ func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
return nil return nil
} }
func (vc *ghRepoCursor) Filter(idxNum int, idxStr string, vals []interface{}) error { func (vc *ghRepoCursor) Filter(idxNum int, idxStr string, vals []any) error {
vc.index = 0 vc.index = 0
return nil return nil
} }

View File

@ -77,7 +77,7 @@ func (vc *seriesCursor) Column(c *sqlite3.SQLiteContext, col int) error {
return nil return nil
} }
func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []interface{}) error { func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []any) error {
switch { switch {
case len(vals) < 1: case len(vals) < 1:
vc.seriesTable.start = 0 vc.seriesTable.start = 0

View File

@ -100,13 +100,13 @@ func preUpdateHookTrampoline(handle unsafe.Pointer, dbHandle uintptr, op int, db
// Use handles to avoid passing Go pointers to C. // Use handles to avoid passing Go pointers to C.
type handleVal struct { type handleVal struct {
db *SQLiteConn db *SQLiteConn
val interface{} val any
} }
var handleLock sync.Mutex var handleLock sync.Mutex
var handleVals = make(map[unsafe.Pointer]handleVal) var handleVals = make(map[unsafe.Pointer]handleVal)
func newHandle(db *SQLiteConn, v interface{}) unsafe.Pointer { func newHandle(db *SQLiteConn, v any) unsafe.Pointer {
handleLock.Lock() handleLock.Lock()
defer handleLock.Unlock() defer handleLock.Unlock()
val := handleVal{db: db, val: v} val := handleVal{db: db, val: v}
@ -124,7 +124,7 @@ func lookupHandleVal(handle unsafe.Pointer) handleVal {
return handleVals[handle] return handleVals[handle]
} }
func lookupHandle(handle unsafe.Pointer) interface{} { func lookupHandle(handle unsafe.Pointer) any {
return lookupHandleVal(handle).val return lookupHandleVal(handle).val
} }
@ -238,7 +238,7 @@ func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
switch typ.Kind() { switch typ.Kind() {
case reflect.Interface: case reflect.Interface:
if typ.NumMethod() != 0 { if typ.NumMethod() != 0 {
return nil, errors.New("the only supported interface type is interface{}") return nil, errors.New("the only supported interface type is any")
} }
return callbackArgGeneric, nil return callbackArgGeneric, nil
case reflect.Slice: case reflect.Slice:

View File

@ -53,7 +53,7 @@ func TestCallbackArgCast(t *testing.T) {
func TestCallbackConverters(t *testing.T) { func TestCallbackConverters(t *testing.T) {
tests := []struct { tests := []struct {
v interface{} v any
err bool err bool
}{ }{
// Unfortunately, we can't tell which converter was returned, // Unfortunately, we can't tell which converter was returned,
@ -104,7 +104,7 @@ func TestCallbackConverters(t *testing.T) {
} }
func TestCallbackReturnAny(t *testing.T) { func TestCallbackReturnAny(t *testing.T) {
udf := func() interface{} { udf := func() any {
return 1 return 1
} }

View File

@ -23,7 +23,7 @@ var errNilPtr = errors.New("destination pointer is nil") // embedded in descript
// convertAssign copies to dest the value in src, converting it if possible. // convertAssign copies to dest the value in src, converting it if possible.
// An error is returned if the copy would result in loss of information. // An error is returned if the copy would result in loss of information.
// dest should be a pointer type. // dest should be a pointer type.
func convertAssign(dest, src interface{}) error { func convertAssign(dest, src any) error {
// Common cases, without reflect. // Common cases, without reflect.
switch s := src.(type) { switch s := src.(type) {
case string: case string:
@ -55,7 +55,7 @@ func convertAssign(dest, src interface{}) error {
} }
*d = string(s) *d = string(s)
return nil return nil
case *interface{}: case *any:
if d == nil { if d == nil {
return errNilPtr return errNilPtr
} }
@ -97,7 +97,7 @@ func convertAssign(dest, src interface{}) error {
} }
case nil: case nil:
switch d := dest.(type) { switch d := dest.(type) {
case *interface{}: case *any:
if d == nil { if d == nil {
return errNilPtr return errNilPtr
} }
@ -149,7 +149,7 @@ func convertAssign(dest, src interface{}) error {
*d = bv.(bool) *d = bv.(bool)
} }
return err return err
case *interface{}: case *any:
*d = src *d = src
return nil return nil
} }
@ -256,7 +256,7 @@ func cloneBytes(b []byte) []byte {
return c return c
} }
func asString(src interface{}) string { func asString(src any) string {
switch v := src.(type) { switch v := src.(type) {
case string: case string:
return v return v

2
doc.go
View File

@ -95,7 +95,7 @@ You can also use database/sql.Conn.Raw (Go >= 1.13):
conn, err := db.Conn(context.Background()) conn, err := db.Conn(context.Background())
// if err != nil { ... } // if err != nil { ... }
defer conn.Close() defer conn.Close()
err = conn.Raw(func (driverConn interface{}) error { err = conn.Raw(func (driverConn any) error {
sqliteConn := driverConn.(*sqlite3.SQLiteConn) sqliteConn := driverConn.(*sqlite3.SQLiteConn)
// ... use sqliteConn // ... use sqliteConn
}) })

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/mattn/go-sqlite3 module github.com/mattn/go-sqlite3
go 1.16 go 1.19
retract ( retract (
[v2.0.0+incompatible, v2.0.6+incompatible] // Accidental; no major changes or features. [v2.0.0+incompatible, v2.0.6+incompatible] // Accidental; no major changes or features.

View File

@ -607,10 +607,9 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// RegisterFunc makes a Go function available as a SQLite function. // RegisterFunc makes a Go function available as a SQLite function.
// //
// The Go function can have arguments of the following types: any // The Go function can have arguments of the following types: any
// numeric type except complex, bool, []byte, string and // numeric type except complex, bool, []byte, string and any.
// interface{}. interface{} arguments are given the direct translation // any arguments are given the direct translation of the SQLite data type:
// of the SQLite data type: int64 for INTEGER, float64 for FLOAT, // int64 for INTEGER, float64 for FLOAT, []byte for BLOB, string for TEXT.
// []byte for BLOB, string for TEXT.
// //
// The function can additionally be variadic, as long as the type of // The function can additionally be variadic, as long as the type of
// the variadic argument is one of the above. // the variadic argument is one of the above.
@ -620,7 +619,7 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// optimizations in its queries. // optimizations in its queries.
// //
// See _example/go_custom_funcs for a detailed example. // See _example/go_custom_funcs for a detailed example.
func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error { func (c *SQLiteConn) RegisterFunc(name string, impl any, pure bool) error {
var fi functionInfo var fi functionInfo
fi.f = reflect.ValueOf(impl) fi.f = reflect.ValueOf(impl)
t := fi.f.Type() t := fi.f.Type()
@ -702,7 +701,7 @@ func sqlite3CreateFunction(db *C.sqlite3, zFunctionName *C.char, nArg C.int, eTe
// return an error in addition to their other return values. // return an error in addition to their other return values.
// //
// See _example/go_custom_funcs for a detailed example. // See _example/go_custom_funcs for a detailed example.
func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error { func (c *SQLiteConn) RegisterAggregator(name string, impl any, pure bool) error {
var ai aggInfo var ai aggInfo
ai.constructor = reflect.ValueOf(impl) ai.constructor = reflect.ValueOf(impl)
t := ai.constructor.Type() t := ai.constructor.Type()

View File

@ -50,15 +50,15 @@ import (
// perhaps using a cryptographic hash function like SHA1. // perhaps using a cryptographic hash function like SHA1.
// CryptEncoderSHA1 encodes a password with SHA1 // CryptEncoderSHA1 encodes a password with SHA1
func CryptEncoderSHA1(pass []byte, hash interface{}) []byte { func CryptEncoderSHA1(pass []byte, hash any) []byte {
h := sha1.Sum(pass) h := sha1.Sum(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA1 encodes a password with SHA1 with the // CryptEncoderSSHA1 encodes a password with SHA1 with the
// configured salt. // configured salt.
func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA1(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha1.Sum(p) h := sha1.Sum(p)
@ -67,15 +67,15 @@ func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
} }
// CryptEncoderSHA256 encodes a password with SHA256 // CryptEncoderSHA256 encodes a password with SHA256
func CryptEncoderSHA256(pass []byte, hash interface{}) []byte { func CryptEncoderSHA256(pass []byte, hash any) []byte {
h := sha256.Sum256(pass) h := sha256.Sum256(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA256 encodes a password with SHA256 // CryptEncoderSSHA256 encodes a password with SHA256
// with the configured salt // with the configured salt
func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA256(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha256.Sum256(p) h := sha256.Sum256(p)
@ -84,15 +84,15 @@ func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte
} }
// CryptEncoderSHA384 encodes a password with SHA384 // CryptEncoderSHA384 encodes a password with SHA384
func CryptEncoderSHA384(pass []byte, hash interface{}) []byte { func CryptEncoderSHA384(pass []byte, hash any) []byte {
h := sha512.Sum384(pass) h := sha512.Sum384(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA384 encodes a password with SHA384 // CryptEncoderSSHA384 encodes a password with SHA384
// with the configured salt // with the configured salt
func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA384(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha512.Sum384(p) h := sha512.Sum384(p)
@ -101,15 +101,15 @@ func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte
} }
// CryptEncoderSHA512 encodes a password with SHA512 // CryptEncoderSHA512 encodes a password with SHA512
func CryptEncoderSHA512(pass []byte, hash interface{}) []byte { func CryptEncoderSHA512(pass []byte, hash any) []byte {
h := sha512.Sum512(pass) h := sha512.Sum512(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA512 encodes a password with SHA512 // CryptEncoderSSHA512 encodes a password with SHA512
// with the configured salt // with the configured salt
func CryptEncoderSSHA512(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA512(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha512.Sum512(p) h := sha512.Sum512(p)

View File

@ -29,7 +29,7 @@ func TestCryptEncoders(t *testing.T) {
} }
for _, e := range tests { for _, e := range tests {
var fn func(pass []byte, hash interface{}) []byte var fn func(pass []byte, hash any) []byte
switch e.enc { switch e.enc {
case "sha1": case "sha1":
fn = CryptEncoderSHA1 fn = CryptEncoderSHA1

View File

@ -45,7 +45,7 @@ func TestBeginTxCancel(t *testing.T) {
} }
}() }()
err = conn.Raw(func(driverConn interface{}) error { err = conn.Raw(func(driverConn any) error {
d, ok := driverConn.(driver.ConnBeginTx) d, ok := driverConn.(driver.ConnBeginTx)
if !ok { if !ok {
t.Fatal("unexpected: wrong type") t.Fatal("unexpected: wrong type")
@ -96,7 +96,7 @@ func TestStmtReadonly(t *testing.T) {
} }
var ro bool var ro bool
c.Raw(func(dc interface{}) error { c.Raw(func(dc any) error {
stmt, err := dc.(*SQLiteConn).Prepare(query) stmt, err := dc.(*SQLiteConn).Prepare(query)
if err != nil { if err != nil {
return err return err

View File

@ -54,10 +54,10 @@ func (d *SQLitePreUpdateData) Count() int {
return int(C.sqlite3_preupdate_count(d.Conn.db)) return int(C.sqlite3_preupdate_count(d.Conn.db))
} }
func (d *SQLitePreUpdateData) row(dest []interface{}, new bool) error { func (d *SQLitePreUpdateData) row(dest []any, new bool) error {
for i := 0; i < d.Count() && i < len(dest); i++ { for i := 0; i < d.Count() && i < len(dest); i++ {
var val *C.sqlite3_value var val *C.sqlite3_value
var src interface{} var src any
// Initially I tried making this just a function pointer argument, but // Initially I tried making this just a function pointer argument, but
// it's absurdly complicated to pass C function pointers. // it's absurdly complicated to pass C function pointers.
@ -95,7 +95,7 @@ func (d *SQLitePreUpdateData) row(dest []interface{}, new bool) error {
// Old populates dest with the row data to be replaced. This works similar to // Old populates dest with the row data to be replaced. This works similar to
// database/sql's Rows.Scan() // database/sql's Rows.Scan()
func (d *SQLitePreUpdateData) Old(dest ...interface{}) error { func (d *SQLitePreUpdateData) Old(dest ...any) error {
if d.Op == SQLITE_INSERT { if d.Op == SQLITE_INSERT {
return errors.New("There is no old row for INSERT operations") return errors.New("There is no old row for INSERT operations")
} }
@ -104,7 +104,7 @@ func (d *SQLitePreUpdateData) Old(dest ...interface{}) error {
// New populates dest with the replacement row data. This works similar to // New populates dest with the replacement row data. This works similar to
// database/sql's Rows.Scan() // database/sql's Rows.Scan()
func (d *SQLitePreUpdateData) New(dest ...interface{}) error { func (d *SQLitePreUpdateData) New(dest ...any) error {
if d.Op == SQLITE_DELETE { if d.Op == SQLITE_DELETE {
return errors.New("There is no new row for DELETE operations") return errors.New("There is no new row for DELETE operations")
} }

View File

@ -18,8 +18,8 @@ type preUpdateHookDataForTest struct {
tableName string tableName string
count int count int
op int op int
oldRow []interface{} oldRow []any
newRow []interface{} newRow []any
} }
func TestPreUpdateHook(t *testing.T) { func TestPreUpdateHook(t *testing.T) {
@ -29,7 +29,7 @@ func TestPreUpdateHook(t *testing.T) {
ConnectHook: func(conn *SQLiteConn) error { ConnectHook: func(conn *SQLiteConn) error {
conn.RegisterPreUpdateHook(func(data SQLitePreUpdateData) { conn.RegisterPreUpdateHook(func(data SQLitePreUpdateData) {
eval := -1 eval := -1
oldRow := []interface{}{eval} oldRow := []any{eval}
if data.Op != SQLITE_INSERT { if data.Op != SQLITE_INSERT {
err := data.Old(oldRow...) err := data.Old(oldRow...)
if err != nil { if err != nil {
@ -38,7 +38,7 @@ func TestPreUpdateHook(t *testing.T) {
} }
eval2 := -1 eval2 := -1
newRow := []interface{}{eval2} newRow := []any{eval2}
if data.Op != SQLITE_DELETE { if data.Op != SQLITE_DELETE {
err := data.New(newRow...) err := data.New(newRow...)
if err != nil { if err != nil {
@ -47,7 +47,7 @@ func TestPreUpdateHook(t *testing.T) {
} }
// tests dest bound checks in loop // tests dest bound checks in loop
var tooSmallRow []interface{} var tooSmallRow []any
if data.Op != SQLITE_INSERT { if data.Op != SQLITE_INSERT {
err := data.Old(tooSmallRow...) err := data.Old(tooSmallRow...)
if err != nil { if err != nil {

View File

@ -54,7 +54,7 @@ func TestSerializeDeserialize(t *testing.T) {
defer srcConn.Close() defer srcConn.Close()
var serialized []byte var serialized []byte
if err := srcConn.Raw(func(raw interface{}) error { if err := srcConn.Raw(func(raw any) error {
var err error var err error
serialized, err = raw.(*SQLiteConn).Serialize("") serialized, err = raw.(*SQLiteConn).Serialize("")
return err return err
@ -80,7 +80,7 @@ func TestSerializeDeserialize(t *testing.T) {
} }
defer destConn.Close() defer destConn.Close()
if err := destConn.Raw(func(raw interface{}) error { if err := destConn.Raw(func(raw any) error {
return raw.(*SQLiteConn).Deserialize(serialized, "") return raw.(*SQLiteConn).Deserialize(serialized, "")
}); err != nil { }); err != nil {
t.Fatal("Failed to deserialize source database:", err) t.Fatal("Failed to deserialize source database:", err)

View File

@ -516,7 +516,7 @@ func goMDestroy(pClientData unsafe.Pointer) {
func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int, argv **C.sqlite3_value) *C.char { func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int, argv **C.sqlite3_value) *C.char {
vtc := lookupHandle(pCursor).(*sqliteVTabCursor) vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
vals := make([]interface{}, 0, argc) vals := make([]any, 0, argc)
for _, v := range args { for _, v := range args {
conv, err := callbackArgGeneric(v) conv, err := callbackArgGeneric(v)
if err != nil { if err != nil {
@ -588,7 +588,7 @@ func goVUpdate(pVTab unsafe.Pointer, argc C.int, argv **C.sqlite3_value, pRowid
if v, ok := vt.vTab.(VTabUpdater); ok { if v, ok := vt.vTab.(VTabUpdater); ok {
// convert argv // convert argv
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
vals := make([]interface{}, 0, argc) vals := make([]any, 0, argc)
for _, v := range args { for _, v := range args {
conv, err := callbackArgGeneric(v) conv, err := callbackArgGeneric(v)
if err != nil { if err != nil {
@ -662,9 +662,9 @@ type VTab interface {
// deleted. // deleted.
// See: https://sqlite.org/vtab.html#xupdate // See: https://sqlite.org/vtab.html#xupdate
type VTabUpdater interface { type VTabUpdater interface {
Delete(interface{}) error Delete(any) error
Insert(interface{}, []interface{}) (int64, error) Insert(any, []any) (int64, error)
Update(interface{}, []interface{}) error Update(any, []any) error
} }
// VTabCursor describes cursors that point into the virtual table and are used // VTabCursor describes cursors that point into the virtual table and are used
@ -673,7 +673,7 @@ type VTabCursor interface {
// http://sqlite.org/vtab.html#xclose // http://sqlite.org/vtab.html#xclose
Close() error Close() error
// http://sqlite.org/vtab.html#xfilter // http://sqlite.org/vtab.html#xfilter
Filter(idxNum int, idxStr string, vals []interface{}) error Filter(idxNum int, idxStr string, vals []any) error
// http://sqlite.org/vtab.html#xnext // http://sqlite.org/vtab.html#xnext
Next() error Next() error
// http://sqlite.org/vtab.html#xeof // http://sqlite.org/vtab.html#xeof

View File

@ -98,7 +98,7 @@ func (vc *testVTabCursor) Close() error {
return nil return nil
} }
func (vc *testVTabCursor) Filter(idxNum int, idxStr string, vals []interface{}) error { func (vc *testVTabCursor) Filter(idxNum int, idxStr string, vals []any) error {
vc.index = 0 vc.index = 0
return nil return nil
} }
@ -236,10 +236,10 @@ func TestVUpdate(t *testing.T) {
if len(vt.data) != 2 { if len(vt.data) != 2 {
t.Fatalf("expected table vt to have exactly 2 rows, got: %d", len(vt.data)) t.Fatalf("expected table vt to have exactly 2 rows, got: %d", len(vt.data))
} }
if !reflect.DeepEqual(vt.data[0], []interface{}{int64(115), "b", "c"}) { if !reflect.DeepEqual(vt.data[0], []any{int64(115), "b", "c"}) {
t.Fatalf("expected table vt entry 0 to be [115 b c], instead: %v", vt.data[0]) t.Fatalf("expected table vt entry 0 to be [115 b c], instead: %v", vt.data[0])
} }
if !reflect.DeepEqual(vt.data[1], []interface{}{int64(116), "d", "e"}) { if !reflect.DeepEqual(vt.data[1], []any{int64(116), "d", "e"}) {
t.Fatalf("expected table vt entry 1 to be [116 d e], instead: %v", vt.data[1]) t.Fatalf("expected table vt entry 1 to be [116 d e], instead: %v", vt.data[1])
} }
@ -273,10 +273,10 @@ func TestVUpdate(t *testing.T) {
if len(vt.data) != 2 { if len(vt.data) != 2 {
t.Fatalf("expected table vt to have exactly 2 rows, got: %d", len(vt.data)) t.Fatalf("expected table vt to have exactly 2 rows, got: %d", len(vt.data))
} }
if !reflect.DeepEqual(vt.data[0], []interface{}{int64(115), "b", "c"}) { if !reflect.DeepEqual(vt.data[0], []any{int64(115), "b", "c"}) {
t.Fatalf("expected table vt entry 0 to be [115 b c], instead: %v", vt.data[0]) t.Fatalf("expected table vt entry 0 to be [115 b c], instead: %v", vt.data[0])
} }
if !reflect.DeepEqual(vt.data[1], []interface{}{int64(117), "f", "e"}) { if !reflect.DeepEqual(vt.data[1], []any{int64(117), "f", "e"}) {
t.Fatalf("expected table vt entry 1 to be [117 f e], instead: %v", vt.data[1]) t.Fatalf("expected table vt entry 1 to be [117 f e], instead: %v", vt.data[1])
} }
@ -297,7 +297,7 @@ func TestVUpdate(t *testing.T) {
if len(vt.data) != 1 { if len(vt.data) != 1 {
t.Fatalf("expected table vt to have exactly 1 row, got: %d", len(vt.data)) t.Fatalf("expected table vt to have exactly 1 row, got: %d", len(vt.data))
} }
if !reflect.DeepEqual(vt.data[0], []interface{}{int64(115), "b", "c"}) { if !reflect.DeepEqual(vt.data[0], []any{int64(115), "b", "c"}) {
t.Fatalf("expected table vt entry 0 to be [115 b c], instead: %v", vt.data[0]) t.Fatalf("expected table vt entry 0 to be [115 b c], instead: %v", vt.data[0])
} }
@ -353,7 +353,7 @@ func (m *vtabUpdateModule) Create(c *SQLiteConn, args []string) (VTab, error) {
} }
// create table // create table
vtab := &vtabUpdateTable{m.t, dbname, tname, cols, typs, make([][]interface{}, 0)} vtab := &vtabUpdateTable{m.t, dbname, tname, cols, typs, make([][]any, 0)}
m.tables[tname] = vtab m.tables[tname] = vtab
return vtab, nil return vtab, nil
} }
@ -370,7 +370,7 @@ type vtabUpdateTable struct {
name string name string
cols []string cols []string
typs []string typs []string
data [][]interface{} data [][]any
} }
func (t *vtabUpdateTable) Open() (VTabCursor, error) { func (t *vtabUpdateTable) Open() (VTabCursor, error) {
@ -389,7 +389,7 @@ func (t *vtabUpdateTable) Destroy() error {
return nil return nil
} }
func (t *vtabUpdateTable) Insert(id interface{}, vals []interface{}) (int64, error) { func (t *vtabUpdateTable) Insert(id any, vals []any) (int64, error) {
var i int64 var i int64
if id == nil { if id == nil {
i, t.data = int64(len(t.data)), append(t.data, vals) i, t.data = int64(len(t.data)), append(t.data, vals)
@ -407,7 +407,7 @@ func (t *vtabUpdateTable) Insert(id interface{}, vals []interface{}) (int64, err
return i, nil return i, nil
} }
func (t *vtabUpdateTable) Update(id interface{}, vals []interface{}) error { func (t *vtabUpdateTable) Update(id any, vals []any) error {
i, ok := id.(int64) i, ok := id.(int64)
if !ok { if !ok {
return fmt.Errorf("id is invalid type: %T", id) return fmt.Errorf("id is invalid type: %T", id)
@ -422,7 +422,7 @@ func (t *vtabUpdateTable) Update(id interface{}, vals []interface{}) error {
return nil return nil
} }
func (t *vtabUpdateTable) Delete(id interface{}) error { func (t *vtabUpdateTable) Delete(id any) error {
i, ok := id.(int64) i, ok := id.(int64)
if !ok { if !ok {
return fmt.Errorf("id is invalid type: %T", id) return fmt.Errorf("id is invalid type: %T", id)
@ -465,7 +465,7 @@ func (c *vtabUpdateCursor) Column(ctxt *SQLiteContext, col int) error {
return nil return nil
} }
func (c *vtabUpdateCursor) Filter(ixNum int, ixName string, vals []interface{}) error { func (c *vtabUpdateCursor) Filter(ixNum int, ixName string, vals []any) error {
return nil return nil
} }
@ -547,7 +547,7 @@ func (vc *testVTabCursorEponymousOnly) Close() error {
return nil return nil
} }
func (vc *testVTabCursorEponymousOnly) Filter(idxNum int, idxStr string, vals []interface{}) error { func (vc *testVTabCursorEponymousOnly) Filter(idxNum int, idxStr string, vals []any) error {
vc.index = 0 vc.index = 0
return nil return nil
} }

View File

@ -625,7 +625,7 @@ func TestTimestamp(t *testing.T) {
timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC) timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)
tzTest := time.FixedZone("TEST", -9*3600-13*60) tzTest := time.FixedZone("TEST", -9*3600-13*60)
tests := []struct { tests := []struct {
value interface{} value any
expected time.Time expected time.Time
}{ }{
{"nonsense", time.Time{}}, {"nonsense", time.Time{}},
@ -827,7 +827,7 @@ func TestFloat32(t *testing.T) {
t.Fatal("Unable to query results:", err) t.Fatal("Unable to query results:", err)
} }
var id interface{} var id any
if err := rows.Scan(&id); err != nil { if err := rows.Scan(&id); err != nil {
t.Fatal("Unable to scan results:", err) t.Fatal("Unable to scan results:", err)
} }
@ -854,7 +854,7 @@ func TestNull(t *testing.T) {
t.Fatal("Unable to query results:", err) t.Fatal("Unable to query results:", err)
} }
var v interface{} var v any
if err := rows.Scan(&v); err != nil { if err := rows.Scan(&v); err != nil {
t.Fatal("Unable to scan results:", err) t.Fatal("Unable to scan results:", err)
} }
@ -998,7 +998,7 @@ func TestTimezoneConversion(t *testing.T) {
timestamp2 := time.Date(2006, time.January, 2, 15, 4, 5, 123456789, time.UTC) timestamp2 := time.Date(2006, time.January, 2, 15, 4, 5, 123456789, time.UTC)
timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC) timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)
tests := []struct { tests := []struct {
value interface{} value any
expected time.Time expected time.Time
}{ }{
{"nonsense", time.Time{}.In(loc)}, {"nonsense", time.Time{}.In(loc)},
@ -1291,7 +1291,7 @@ const CurrentTimeStamp = "2006-01-02 15:04:05"
type TimeStamp struct{ *time.Time } type TimeStamp struct{ *time.Time }
func (t TimeStamp) Scan(value interface{}) error { func (t TimeStamp) Scan(value any) error {
var err error var err error
switch v := value.(type) { switch v := value.(type) {
case string: case string:
@ -1335,7 +1335,7 @@ func TestFunctionRegistration(t *testing.T) {
regex := func(re, s string) (bool, error) { regex := func(re, s string) (bool, error) {
return regexp.MatchString(re, s) return regexp.MatchString(re, s)
} }
generic := func(a interface{}) int64 { generic := func(a any) int64 {
switch a.(type) { switch a.(type) {
case int64: case int64:
return 1 return 1
@ -1356,7 +1356,7 @@ func TestFunctionRegistration(t *testing.T) {
} }
return ret return ret
} }
variadicGeneric := func(a ...interface{}) int64 { variadicGeneric := func(a ...any) int64 {
return int64(len(a)) return int64(len(a))
} }
@ -1406,7 +1406,7 @@ func TestFunctionRegistration(t *testing.T) {
ops := []struct { ops := []struct {
query string query string
expected interface{} expected any
}{ }{
{"SELECT addi8_16_32(1,2)", int32(3)}, {"SELECT addi8_16_32(1,2)", int32(3)},
{"SELECT addi64(1,2)", int64(3)}, {"SELECT addi64(1,2)", int64(3)},
@ -1497,18 +1497,18 @@ func TestAggregatorRegistration(t *testing.T) {
} }
type mode struct { type mode struct {
counts map[interface{}]int counts map[any]int
top interface{} top any
topCount int topCount int
} }
func newMode() *mode { func newMode() *mode {
return &mode{ return &mode{
counts: map[interface{}]int{}, counts: map[any]int{},
} }
} }
func (m *mode) Step(x interface{}) { func (m *mode) Step(x any) {
m.counts[x]++ m.counts[x]++
c := m.counts[x] c := m.counts[x]
if c > m.topCount { if c > m.topCount {
@ -1517,7 +1517,7 @@ func (m *mode) Step(x interface{}) {
} }
} }
func (m *mode) Done() interface{} { func (m *mode) Done() any {
return m.top return m.top
} }
@ -1871,7 +1871,7 @@ func TestNonColumnString(t *testing.T) {
} }
defer db.Close() defer db.Close()
var x interface{} var x any
if err := db.QueryRow("SELECT 'hello'").Scan(&x); err != nil { if err := db.QueryRow("SELECT 'hello'").Scan(&x); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -2113,7 +2113,7 @@ var benchmarks = []testing.InternalBenchmark{
{Name: "BenchmarkStmtRows", F: benchmarkStmtRows}, {Name: "BenchmarkStmtRows", F: benchmarkStmtRows},
} }
func (db *TestDB) mustExec(sql string, args ...interface{}) sql.Result { func (db *TestDB) mustExec(sql string, args ...any) sql.Result {
res, err := db.Exec(sql, args...) res, err := db.Exec(sql, args...)
if err != nil { if err != nil {
db.Fatalf("Error running %q: %v", sql, err) db.Fatalf("Error running %q: %v", sql, err)

View File

@ -74,7 +74,7 @@ func scanType(cdt string) reflect.Type {
case SQLITE_TIME: case SQLITE_TIME:
return reflect.TypeOf(sql.NullTime{}) return reflect.TypeOf(sql.NullTime{})
} }
return reflect.TypeOf(new(interface{})) return reflect.TypeOf(new(any))
} }
func databaseTypeConvSqlite(t string) int { func databaseTypeConvSqlite(t string) int {

View File

@ -28,10 +28,10 @@ type (
) )
func (SQLiteDriver) Open(s string) (driver.Conn, error) { return nil, errorMsg } func (SQLiteDriver) Open(s string) (driver.Conn, error) { return nil, errorMsg }
func (c *SQLiteConn) RegisterAggregator(string, interface{}, bool) error { return errorMsg } func (c *SQLiteConn) RegisterAggregator(string, any, bool) error { return errorMsg }
func (c *SQLiteConn) RegisterAuthorizer(func(int, string, string, string) int) {} func (c *SQLiteConn) RegisterAuthorizer(func(int, string, string, string) int) {}
func (c *SQLiteConn) RegisterCollation(string, func(string, string) int) error { return errorMsg } func (c *SQLiteConn) RegisterCollation(string, func(string, string) int) error { return errorMsg }
func (c *SQLiteConn) RegisterCommitHook(func() int) {} func (c *SQLiteConn) RegisterCommitHook(func() int) {}
func (c *SQLiteConn) RegisterFunc(string, interface{}, bool) error { return errorMsg } func (c *SQLiteConn) RegisterFunc(string, any, bool) error { return errorMsg }
func (c *SQLiteConn) RegisterRollbackHook(func()) {} func (c *SQLiteConn) RegisterRollbackHook(func()) {}
func (c *SQLiteConn) RegisterUpdateHook(func(int, string, string, int64)) {} func (c *SQLiteConn) RegisterUpdateHook(func(int, string, string, int64)) {}