v0.0.49
This commit is contained in:
parent
10ddc7c190
commit
24e923fe84
@ -50,7 +50,6 @@ func ScanSingle[TData any](rows *sqlx.Rows, mode StructScanMode, sec StructScanS
|
||||
return *new(TData), err
|
||||
}
|
||||
} else if mode == SModeExtended {
|
||||
var data TData
|
||||
err := strscan.StructScanExt(&data)
|
||||
if err != nil {
|
||||
return *new(TData), err
|
||||
|
@ -113,7 +113,7 @@ func (r *StructScanner) StructScanExt(dest any) error {
|
||||
|
||||
if _, ok := forcenulled[k]; !ok {
|
||||
f := reflectx.FieldByIndexes(v, traversal[0:i])
|
||||
f.Set(reflect.New(f.Type().Elem())) // set to nil
|
||||
f.Set(reflect.Zero(f.Type())) // set to nil
|
||||
forcenulled[k] = true
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ func (r *StructScanner) StructScanExt(dest any) error {
|
||||
return errors.New(fmt.Sprintf("Cannot set field %v to NULL value from column '%s' (type: %s)", traversal, r.columns[i], f.Type().String()))
|
||||
}
|
||||
|
||||
f.Set(reflect.New(f.Type().Elem())) // set to nil
|
||||
f.Set(reflect.Zero(f.Type())) // set to nil
|
||||
} else {
|
||||
f.Set(val3)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user