Skip to content

Commit b4bb4bb

Browse files
committed
fix
1 parent a40d3b2 commit b4bb4bb

File tree

2 files changed

+286
-193
lines changed

2 files changed

+286
-193
lines changed

internal/bind/params.go

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,25 @@ var (
2424
errMultipleQueryParameters = errors.New("only one query arg *table.QueryParameters allowed")
2525
)
2626

27-
// Benchmarking of asUUID
28-
//
29-
// explicit UUID 2566760 462.1 ns/op 32 B/op 2 allocs/op
30-
// asUUID 2103366 595.9 ns/op 48 B/op 3 allocs/op
31-
func asUUID(v interface{}) (value.Value, bool) {
32-
// explicit casting of type [16]byte to uuid.UUID will success,
33-
// but casting of [16]byte to some interface with methods from uuid.UUID will failed
34-
if _, ok := v.(interface {
35-
URN() string
36-
}); !ok {
37-
return nil, false
38-
}
27+
var (
28+
uuidType = reflect.TypeOf(uuid.UUID{})
29+
uuidPtrType = reflect.TypeOf((*uuid.UUID)(nil))
30+
)
3931

40-
switch vv := v.(type) {
41-
case uuid.UUID:
42-
return value.Uuid(vv), true
43-
case *uuid.UUID:
32+
func asUUID(v interface{}) (value.Value, bool) {
33+
switch reflect.TypeOf(v) {
34+
case uuidType:
35+
return value.Uuid(v.(uuid.UUID)), true
36+
case uuidPtrType:
37+
vv := v.(*uuid.UUID)
4438
if vv == nil {
4539
return value.NullValue(types.UUID), true
4640
}
4741

48-
return value.OptionalValue(value.Uuid(*vv)), true
49-
default:
50-
return nil, false
42+
return value.OptionalValue(value.Uuid(*(v.(*uuid.UUID)))), true
5143
}
44+
45+
return nil, false
5246
}
5347

5448
func toType(v interface{}) (_ types.Type, err error) { //nolint:funlen

0 commit comments

Comments
 (0)