dv.Set(reflect.New(dv.Type().Elem()))
return convertAssignRows(dv.Interface(), src, rows)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ if src == nil {
+ return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
+ }
s := asString(src)
i64, err := strconv.ParseInt(s, 10, dv.Type().Bits())
if err != nil {
dv.SetInt(i64)
return nil
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ if src == nil {
+ return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
+ }
s := asString(src)
u64, err := strconv.ParseUint(s, 10, dv.Type().Bits())
if err != nil {
dv.SetUint(u64)
return nil
case reflect.Float32, reflect.Float64:
+ if src == nil {
+ return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
+ }
s := asString(src)
f64, err := strconv.ParseFloat(s, dv.Type().Bits())
if err != nil {
dv.SetFloat(f64)
return nil
case reflect.String:
+ if src == nil {
+ return fmt.Errorf("converting NULL to %s is unsupported", dv.Kind())
+ }
switch v := src.(type) {
case string:
dv.SetString(v)
{
name: "int",
input: &date2,
- expectedError: `sql: Scan error on column index 0, name "bdate": converting driver.Value type <nil> ("<nil>") to a int: invalid syntax`,
+ expectedError: `sql: Scan error on column index 0, name "bdate": converting NULL to int is unsupported`,
},
}