/
githubmirror
/
ydb-go-sql
Обзор
Документация
Войти
/
githubmirror
/
ydb-go-sql
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
internal/check/check.go
61 строка
1 KB
asmyasnikov
draft
18 дек 2021, 14:18
18 дек 2021, 14:18
4ee29e6
Код
Авторство
О чём код?
package check import ( "database/sql/driver" "fmt" "github.com/ydb-platform/ydb-go-sdk/v3/table/types" ) func NamedValue(v *driver.NamedValue) (err error) { if v.Name == "" { return fmt.Errorf("ydb: only named parameters are supported") } if valuer, ok := v.Value.(driver.Valuer); ok { v.Value, err = valuer.Value() if err != nil { return fmt.Errorf("ydb: driver.Valuer error: %w", err) } } switch x := v.Value.(type) { case types.Value: // OK. case bool: v.Value = types.BoolValue(x) case int8: v.Value = types.Int8Value(x) case uint8: v.Value = types.Uint8Value(x) case int16: v.Value = types.Int16Value(x) case uint16: v.Value = types.Uint16Value(x) case int32: v.Value = types.Int32Value(x) case uint32: v.Value = types.Uint32Value(x) case int64: v.Value = types.Int64Value(x) case uint64: v.Value = types.Uint64Value(x) case float32: v.Value = types.FloatValue(x) case float64: v.Value = types.DoubleValue(x) case []byte: v.Value = types.StringValue(x) case string: v.Value = types.UTF8Value(x) case [16]byte: v.Value = types.UUIDValue(x) default: return fmt.Errorf("ydb: unsupported type: %T", x) } v.Name = "$" + v.Name return nil }