aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/go.yaml4
-rw-r--r--_example/limit/limit.go6
-rw-r--r--_example/vtable/vtable.go2
-rw-r--r--_example/vtable_eponymous_only/vtable.go2
-rw-r--r--callback.go8
-rw-r--r--callback_test.go4
-rw-r--r--convert.go10
-rw-r--r--doc.go2
-rw-r--r--go.mod2
-rw-r--r--sqlite3.go11
-rw-r--r--sqlite3_func_crypt.go24
-rw-r--r--sqlite3_func_crypt_test.go2
-rw-r--r--sqlite3_go113_test.go4
-rw-r--r--sqlite3_opt_preupdate_hook.go8
-rw-r--r--sqlite3_opt_preupdate_hook_test.go10
-rw-r--r--sqlite3_opt_serialize_test.go4
-rw-r--r--sqlite3_opt_vtable.go12
-rw-r--r--sqlite3_opt_vtable_test.go26
-rw-r--r--sqlite3_test.go30
-rw-r--r--sqlite3_type.go2
-rw-r--r--static_mock.go4
21 files changed, 88 insertions, 89 deletions
diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml
index 923274b..c96bf31 100644
--- a/.github/workflows/go.yaml
+++ b/.github/workflows/go.yaml
@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
- go: ['1.18', '1.19', '1.20']
+ go: ['1.19', '1.20', '1.21']
fail-fast: false
env:
OS: ${{ matrix.os }}
@@ -64,7 +64,7 @@ jobs:
strategy:
matrix:
- go: ['1.18', '1.19', '1.20']
+ go: ['1.19', '1.20', '1.21']
fail-fast: false
env:
OS: windows-latest
diff --git a/_example/limit/limit.go b/_example/limit/limit.go
index bcba819..c1adfe8 100644
--- a/_example/limit/limit.go
+++ b/_example/limit/limit.go
@@ -10,9 +10,9 @@ import (
"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)
- args = make([]interface{}, n*2)
+ args = make([]any, n*2)
pos := 0
for i := 0; i < n; i++ {
values[i] = "(?, ?)"
@@ -27,7 +27,7 @@ func createBulkInsertQuery(n int, start int) (query string, args []interface{})
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)
if err != nil {
return
diff --git a/_example/vtable/vtable.go b/_example/vtable/vtable.go
index 10d12a9..c65535b 100644
--- a/_example/vtable/vtable.go
+++ b/_example/vtable/vtable.go
@@ -93,7 +93,7 @@ func (vc *ghRepoCursor) Column(c *sqlite3.SQLiteContext, col int) error {
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
return nil
}
diff --git a/_example/vtable_eponymous_only/vtable.go b/_example/vtable_eponymous_only/vtable.go
index 49fc0b7..9f22ebc 100644
--- a/_example/vtable_eponymous_only/vtable.go
+++ b/_example/vtable_eponymous_only/vtable.go
@@ -77,7 +77,7 @@ func (vc *seriesCursor) Column(c *sqlite3.SQLiteContext, col int) error {
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 {
case len(vals) < 1:
vc.seriesTable.start = 0
diff --git a/callback.go b/callback.go
index d305691..0fb25a1 100644
--- a/callback.go
+++ b/callback.go
@@ -100,13 +100,13 @@ func preUpdateHookTrampoline(handle unsafe.Pointer, dbHandle uintptr, op int, db
// Use handles to avoid passing Go pointers to C.
type handleVal struct {
db *SQLiteConn
- val interface{}
+ val any
}
var handleLock sync.Mutex
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()
defer handleLock.Unlock()
val := handleVal{db: db, val: v}
@@ -124,7 +124,7 @@ func lookupHandleVal(handle unsafe.Pointer) handleVal {
return handleVals[handle]
}
-func lookupHandle(handle unsafe.Pointer) interface{} {
+func lookupHandle(handle unsafe.Pointer) any {
return lookupHandleVal(handle).val
}
@@ -238,7 +238,7 @@ func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
switch typ.Kind() {
case reflect.Interface:
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
case reflect.Slice:
diff --git a/callback_test.go b/callback_test.go
index b09122a..c75b0ff 100644
--- a/callback_test.go
+++ b/callback_test.go
@@ -53,7 +53,7 @@ func TestCallbackArgCast(t *testing.T) {
func TestCallbackConverters(t *testing.T) {
tests := []struct {
- v interface{}
+ v any
err bool
}{
// Unfortunately, we can't tell which converter was returned,
@@ -104,7 +104,7 @@ func TestCallbackConverters(t *testing.T) {
}
func TestCallbackReturnAny(t *testing.T) {
- udf := func() interface{} {
+ udf := func() any {
return 1
}
diff --git a/convert.go b/convert.go
index 0385073..f7a9dcd 100644
--- a/convert.go
+++ b/convert.go
@@ -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.
// An error is returned if the copy would result in loss of information.
// dest should be a pointer type.
-func convertAssign(dest, src interface{}) error {
+func convertAssign(dest, src any) error {
// Common cases, without reflect.
switch s := src.(type) {
case string:
@@ -55,7 +55,7 @@ func convertAssign(dest, src interface{}) error {
}
*d = string(s)
return nil
- case *interface{}:
+ case *any:
if d == nil {
return errNilPtr
}
@@ -97,7 +97,7 @@ func convertAssign(dest, src interface{}) error {
}
case nil:
switch d := dest.(type) {
- case *interface{}:
+ case *any:
if d == nil {
return errNilPtr
}
@@ -149,7 +149,7 @@ func convertAssign(dest, src interface{}) error {
*d = bv.(bool)
}
return err
- case *interface{}:
+ case *any:
*d = src
return nil
}
@@ -256,7 +256,7 @@ func cloneBytes(b []byte) []byte {
return c
}
-func asString(src interface{}) string {
+func asString(src any) string {
switch v := src.(type) {
case string:
return v
diff --git a/doc.go b/doc.go
index ac27633..2355893 100644
--- a/doc.go
+++ b/doc.go
@@ -95,7 +95,7 @@ You can also use database/sql.Conn.Raw (Go >= 1.13):
conn, err := db.Conn(context.Background())
// if err != nil { ... }
defer conn.Close()
- err = conn.Raw(func (driverConn interface{}) error {
+ err = conn.Raw(func (driverConn any) error {
sqliteConn := driverConn.(*sqlite3.SQLiteConn)
// ... use sqliteConn
})
diff --git a/go.mod b/go.mod
index 89788ab..e342dcc 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/mattn/go-sqlite3
-go 1.16
+go 1.19
retract (
[v2.0.0+incompatible, v2.0.6+incompatible] // Accidental; no major changes or features.
diff --git a/sqlite3.go b/sqlite3.go
index 5764182..b6404b7 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -607,10 +607,9 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// RegisterFunc makes a Go function available as a SQLite function.
//
// The Go function can have arguments of the following types: any
-// numeric type except complex, bool, []byte, string and
-// interface{}. interface{} arguments are given the direct translation
-// of the SQLite data type: int64 for INTEGER, float64 for FLOAT,
-// []byte for BLOB, string for TEXT.
+// numeric type except complex, bool, []byte, string and any.
+// any arguments are given the direct translation of the SQLite data type:
+// int64 for INTEGER, float64 for FLOAT, []byte for BLOB, string for TEXT.
//
// The function can additionally be variadic, as long as the type of
// 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.
//
// 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
fi.f = reflect.ValueOf(impl)
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.
//
// 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
ai.constructor = reflect.ValueOf(impl)
t := ai.constructor.Type()
diff --git a/sqlite3_func_crypt.go b/sqlite3_func_crypt.go
index afd9333..bd9a3bc 100644
--- a/sqlite3_func_crypt.go
+++ b/sqlite3_func_crypt.go
@@ -50,15 +50,15 @@ import (
// perhaps using a cryptographic hash function like 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)
return h[:]
}
// CryptEncoderSSHA1 encodes a password with SHA1 with the
// configured salt.
-func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
- return func(pass []byte, hash interface{}) []byte {
+func CryptEncoderSSHA1(salt string) func(pass []byte, hash any) []byte {
+ return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha1.Sum(p)
@@ -67,15 +67,15 @@ func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
}
// CryptEncoderSHA256 encodes a password with SHA256
-func CryptEncoderSHA256(pass []byte, hash interface{}) []byte {
+func CryptEncoderSHA256(pass []byte, hash any) []byte {
h := sha256.Sum256(pass)
return h[:]
}
// CryptEncoderSSHA256 encodes a password with SHA256
// with the configured salt
-func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte {
- return func(pass []byte, hash interface{}) []byte {
+func CryptEncoderSSHA256(salt string) func(pass []byte, hash any) []byte {
+ return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha256.Sum256(p)
@@ -84,15 +84,15 @@ func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte
}
// CryptEncoderSHA384 encodes a password with SHA384
-func CryptEncoderSHA384(pass []byte, hash interface{}) []byte {
+func CryptEncoderSHA384(pass []byte, hash any) []byte {
h := sha512.Sum384(pass)
return h[:]
}
// CryptEncoderSSHA384 encodes a password with SHA384
// with the configured salt
-func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte {
- return func(pass []byte, hash interface{}) []byte {
+func CryptEncoderSSHA384(salt string) func(pass []byte, hash any) []byte {
+ return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha512.Sum384(p)
@@ -101,15 +101,15 @@ func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte
}
// CryptEncoderSHA512 encodes a password with SHA512
-func CryptEncoderSHA512(pass []byte, hash interface{}) []byte {
+func CryptEncoderSHA512(pass []byte, hash any) []byte {
h := sha512.Sum512(pass)
return h[:]
}
// CryptEncoderSSHA512 encodes a password with SHA512
// with the configured salt
-func CryptEncoderSSHA512(salt string) func(pass []byte, hash interface{}) []byte {
- return func(pass []byte, hash interface{}) []byte {
+func CryptEncoderSSHA512(salt string) func(pass []byte, hash any) []byte {
+ return func(pass []byte, hash any) []byte {
s := []byte(salt)
p := append(pass, s...)
h := sha512.Sum512(p)
diff --git a/sqlite3_func_crypt_test.go b/sqlite3_func_crypt_test.go
index 0329ca8..e37b467 100644
--- a/sqlite3_func_crypt_test.go
+++ b/sqlite3_func_crypt_test.go
@@ -29,7 +29,7 @@ func TestCryptEncoders(t *testing.T) {
}
for _, e := range tests {
- var fn func(pass []byte, hash interface{}) []byte
+ var fn func(pass []byte, hash any) []byte
switch e.enc {
case "sha1":
fn = CryptEncoderSHA1
diff --git a/sqlite3_go113_test.go b/sqlite3_go113_test.go
index a010cb7..28d404c 100644
--- a/sqlite3_go113_test.go
+++ b/sqlite3_go113_test.go
@@ -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)
if !ok {
t.Fatal("unexpected: wrong type")
@@ -96,7 +96,7 @@ func TestStmtReadonly(t *testing.T) {
}
var ro bool
- c.Raw(func(dc interface{}) error {
+ c.Raw(func(dc any) error {
stmt, err := dc.(*SQLiteConn).Prepare(query)
if err != nil {
return err
diff --git a/sqlite3_opt_preupdate_hook.go b/sqlite3_opt_preupdate_hook.go
index b43e482..9cd0964 100644
--- a/sqlite3_opt_preupdate_hook.go
+++ b/sqlite3_opt_preupdate_hook.go
@@ -54,10 +54,10 @@ func (d *SQLitePreUpdateData) Count() int {
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++ {
var val *C.sqlite3_value
- var src interface{}
+ var src any
// Initially I tried making this just a function pointer argument, but
// 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
// database/sql's Rows.Scan()
-func (d *SQLitePreUpdateData) Old(dest ...interface{}) error {
+func (d *SQLitePreUpdateData) Old(dest ...any) error {
if d.Op == SQLITE_INSERT {
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
// database/sql's Rows.Scan()
-func (d *SQLitePreUpdateData) New(dest ...interface{}) error {
+func (d *SQLitePreUpdateData) New(dest ...any) error {
if d.Op == SQLITE_DELETE {
return errors.New("There is no new row for DELETE operations")
}
diff --git a/sqlite3_opt_preupdate_hook_test.go b/sqlite3_opt_preupdate_hook_test.go
index 20c8766..c3df415 100644
--- a/sqlite3_opt_preupdate_hook_test.go
+++ b/sqlite3_opt_preupdate_hook_test.go
@@ -18,8 +18,8 @@ type preUpdateHookDataForTest struct {
tableName string
count int
op int
- oldRow []interface{}
- newRow []interface{}
+ oldRow []any
+ newRow []any
}
func TestPreUpdateHook(t *testing.T) {
@@ -29,7 +29,7 @@ func TestPreUpdateHook(t *testing.T) {
ConnectHook: func(conn *SQLiteConn) error {
conn.RegisterPreUpdateHook(func(data SQLitePreUpdateData) {
eval := -1
- oldRow := []interface{}{eval}
+ oldRow := []any{eval}
if data.Op != SQLITE_INSERT {
err := data.Old(oldRow...)
if err != nil {
@@ -38,7 +38,7 @@ func TestPreUpdateHook(t *testing.T) {
}
eval2 := -1
- newRow := []interface{}{eval2}
+ newRow := []any{eval2}
if data.Op != SQLITE_DELETE {
err := data.New(newRow...)
if err != nil {
@@ -47,7 +47,7 @@ func TestPreUpdateHook(t *testing.T) {
}
// tests dest bound checks in loop
- var tooSmallRow []interface{}
+ var tooSmallRow []any
if data.Op != SQLITE_INSERT {
err := data.Old(tooSmallRow...)
if err != nil {
diff --git a/sqlite3_opt_serialize_test.go b/sqlite3_opt_serialize_test.go
index 624c5a9..d6e162a 100644
--- a/sqlite3_opt_serialize_test.go
+++ b/sqlite3_opt_serialize_test.go
@@ -54,7 +54,7 @@ func TestSerializeDeserialize(t *testing.T) {
defer srcConn.Close()
var serialized []byte
- if err := srcConn.Raw(func(raw interface{}) error {
+ if err := srcConn.Raw(func(raw any) error {
var err error
serialized, err = raw.(*SQLiteConn).Serialize("")
return err
@@ -80,7 +80,7 @@ func TestSerializeDeserialize(t *testing.T) {
}
defer destConn.Close()
- if err := destConn.Raw(func(raw interface{}) error {
+ if err := destConn.Raw(func(raw any) error {
return raw.(*SQLiteConn).Deserialize(serialized, "")
}); err != nil {
t.Fatal("Failed to deserialize source database:", err)
diff --git a/sqlite3_opt_vtable.go b/sqlite3_opt_vtable.go
index 4a93c46..7b6b68f 100644
--- a/sqlite3_opt_vtable.go
+++ b/sqlite3_opt_vtable.go
@@ -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 {
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
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 {
conv, err := callbackArgGeneric(v)
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 {
// convert argv
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 {
conv, err := callbackArgGeneric(v)
if err != nil {
@@ -662,9 +662,9 @@ type VTab interface {
// deleted.
// See: https://sqlite.org/vtab.html#xupdate
type VTabUpdater interface {
- Delete(interface{}) error
- Insert(interface{}, []interface{}) (int64, error)
- Update(interface{}, []interface{}) error
+ Delete(any) error
+ Insert(any, []any) (int64, error)
+ Update(any, []any) error
}
// 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
Close() error
// 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
Next() error
// http://sqlite.org/vtab.html#xeof
diff --git a/sqlite3_opt_vtable_test.go b/sqlite3_opt_vtable_test.go
index aae646d..64511e2 100644
--- a/sqlite3_opt_vtable_test.go
+++ b/sqlite3_opt_vtable_test.go
@@ -98,7 +98,7 @@ func (vc *testVTabCursor) Close() error {
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
return nil
}
@@ -236,10 +236,10 @@ func TestVUpdate(t *testing.T) {
if len(vt.data) != 2 {
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])
}
- 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])
}
@@ -273,10 +273,10 @@ func TestVUpdate(t *testing.T) {
if len(vt.data) != 2 {
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])
}
- 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])
}
@@ -297,7 +297,7 @@ func TestVUpdate(t *testing.T) {
if len(vt.data) != 1 {
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])
}
@@ -353,7 +353,7 @@ func (m *vtabUpdateModule) Create(c *SQLiteConn, args []string) (VTab, error) {
}
// 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
return vtab, nil
}
@@ -370,7 +370,7 @@ type vtabUpdateTable struct {
name string
cols []string
typs []string
- data [][]interface{}
+ data [][]any
}
func (t *vtabUpdateTable) Open() (VTabCursor, error) {
@@ -389,7 +389,7 @@ func (t *vtabUpdateTable) Destroy() error {
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
if id == nil {
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
}
-func (t *vtabUpdateTable) Update(id interface{}, vals []interface{}) error {
+func (t *vtabUpdateTable) Update(id any, vals []any) error {
i, ok := id.(int64)
if !ok {
return fmt.Errorf("id is invalid type: %T", id)
@@ -422,7 +422,7 @@ func (t *vtabUpdateTable) Update(id interface{}, vals []interface{}) error {
return nil
}
-func (t *vtabUpdateTable) Delete(id interface{}) error {
+func (t *vtabUpdateTable) Delete(id any) error {
i, ok := id.(int64)
if !ok {
return fmt.Errorf("id is invalid type: %T", id)
@@ -465,7 +465,7 @@ func (c *vtabUpdateCursor) Column(ctxt *SQLiteContext, col int) error {
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
}
@@ -547,7 +547,7 @@ func (vc *testVTabCursorEponymousOnly) Close() error {
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
return nil
}
diff --git a/sqlite3_test.go b/sqlite3_test.go
index 326361e..5bcc723 100644
--- a/sqlite3_test.go
+++ b/sqlite3_test.go
@@ -625,7 +625,7 @@ func TestTimestamp(t *testing.T) {
timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)
tzTest := time.FixedZone("TEST", -9*3600-13*60)
tests := []struct {
- value interface{}
+ value any
expected time.Time
}{
{"nonsense", time.Time{}},
@@ -827,7 +827,7 @@ func TestFloat32(t *testing.T) {
t.Fatal("Unable to query results:", err)
}
- var id interface{}
+ var id any
if err := rows.Scan(&id); err != nil {
t.Fatal("Unable to scan results:", err)
}
@@ -854,7 +854,7 @@ func TestNull(t *testing.T) {
t.Fatal("Unable to query results:", err)
}
- var v interface{}
+ var v any
if err := rows.Scan(&v); err != nil {
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)
timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)
tests := []struct {
- value interface{}
+ value any
expected time.Time
}{
{"nonsense", time.Time{}.In(loc)},
@@ -1291,7 +1291,7 @@ const CurrentTimeStamp = "2006-01-02 15:04:05"
type TimeStamp struct{ *time.Time }
-func (t TimeStamp) Scan(value interface{}) error {
+func (t TimeStamp) Scan(value any) error {
var err error
switch v := value.(type) {
case string:
@@ -1335,7 +1335,7 @@ func TestFunctionRegistration(t *testing.T) {
regex := func(re, s string) (bool, error) {
return regexp.MatchString(re, s)
}
- generic := func(a interface{}) int64 {
+ generic := func(a any) int64 {
switch a.(type) {
case int64:
return 1
@@ -1356,7 +1356,7 @@ func TestFunctionRegistration(t *testing.T) {
}
return ret
}
- variadicGeneric := func(a ...interface{}) int64 {
+ variadicGeneric := func(a ...any) int64 {
return int64(len(a))
}
@@ -1406,7 +1406,7 @@ func TestFunctionRegistration(t *testing.T) {
ops := []struct {
query string
- expected interface{}
+ expected any
}{
{"SELECT addi8_16_32(1,2)", int32(3)},
{"SELECT addi64(1,2)", int64(3)},
@@ -1497,18 +1497,18 @@ func TestAggregatorRegistration(t *testing.T) {
}
type mode struct {
- counts map[interface{}]int
- top interface{}
+ counts map[any]int
+ top any
topCount int
}
func newMode() *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]++
c := m.counts[x]
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
}
@@ -1871,7 +1871,7 @@ func TestNonColumnString(t *testing.T) {
}
defer db.Close()
- var x interface{}
+ var x any
if err := db.QueryRow("SELECT 'hello'").Scan(&x); err != nil {
t.Fatal(err)
}
@@ -2113,7 +2113,7 @@ var benchmarks = []testing.InternalBenchmark{
{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...)
if err != nil {
db.Fatalf("Error running %q: %v", sql, err)
diff --git a/sqlite3_type.go b/sqlite3_type.go
index 0fd8210..20537a0 100644
--- a/sqlite3_type.go
+++ b/sqlite3_type.go
@@ -74,7 +74,7 @@ func scanType(cdt string) reflect.Type {
case SQLITE_TIME:
return reflect.TypeOf(sql.NullTime{})
}
- return reflect.TypeOf(new(interface{}))
+ return reflect.TypeOf(new(any))
}
func databaseTypeConvSqlite(t string) int {
diff --git a/static_mock.go b/static_mock.go
index f19e842..59c2444 100644
--- a/static_mock.go
+++ b/static_mock.go
@@ -28,10 +28,10 @@ type (
)
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) RegisterCollation(string, func(string, string) int) error { return errorMsg }
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) RegisterUpdateHook(func(int, string, string, int64)) {}