This commit is contained in:
Mike Schwörer 2022-12-23 19:11:18 +01:00
parent 10ddc7c190
commit 24e923fe84
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 2 additions and 3 deletions

View File

@ -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

View File

@ -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)
}