mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Remove unneeded generics.
This commit is contained in:
@@ -546,8 +546,8 @@ func (s *stmt) setupBindings(args []driver.NamedValue) (err error) {
|
|||||||
err = s.Stmt.BindTime(id, a, s.tmWrite)
|
err = s.Stmt.BindTime(id, a, s.tmWrite)
|
||||||
case util.JSON:
|
case util.JSON:
|
||||||
err = s.Stmt.BindJSON(id, a.Value)
|
err = s.Stmt.BindJSON(id, a.Value)
|
||||||
case util.PointerUnwrap:
|
case util.Pointer:
|
||||||
err = s.Stmt.BindPointer(id, util.UnwrapPointer(a))
|
err = s.Stmt.BindPointer(id, a.Value)
|
||||||
case nil:
|
case nil:
|
||||||
err = s.Stmt.BindNull(id)
|
err = s.Stmt.BindNull(id)
|
||||||
default:
|
default:
|
||||||
@@ -565,7 +565,7 @@ func (s *stmt) CheckNamedValue(arg *driver.NamedValue) error {
|
|||||||
switch arg.Value.(type) {
|
switch arg.Value.(type) {
|
||||||
case bool, int, int64, float64, string, []byte,
|
case bool, int, int64, float64, string, []byte,
|
||||||
time.Time, sqlite3.ZeroBlob,
|
time.Time, sqlite3.ZeroBlob,
|
||||||
util.JSON, util.PointerUnwrap,
|
util.JSON, util.Pointer,
|
||||||
nil:
|
nil:
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
type Pointer[T any] struct{ Value T }
|
type Pointer struct{ Value any }
|
||||||
|
|
||||||
func (p Pointer[T]) unwrap() any { return p.Value }
|
|
||||||
|
|
||||||
type PointerUnwrap interface{ unwrap() any }
|
|
||||||
|
|
||||||
func UnwrapPointer(p PointerUnwrap) any {
|
|
||||||
return p.unwrap()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package util
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestUnwrapPointer(t *testing.T) {
|
|
||||||
p := Pointer[float64]{Value: math.Pi}
|
|
||||||
if got := UnwrapPointer(p); got != math.Pi {
|
|
||||||
t.Errorf("want π, got %v", got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,6 @@ import "github.com/ncruces/go-sqlite3/internal/util"
|
|||||||
// [Value.Pointer], or [Context.ResultPointer].
|
// [Value.Pointer], or [Context.ResultPointer].
|
||||||
//
|
//
|
||||||
// https://sqlite.org/bindptr.html
|
// https://sqlite.org/bindptr.html
|
||||||
func Pointer[T any](value T) any {
|
func Pointer(value any) any {
|
||||||
return util.Pointer[T]{Value: value}
|
return util.Pointer{Value: value}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user