[#5958] fixed RecordQuery() custom struct scanning
This commit is contained in:
@@ -102,11 +102,6 @@ func (app *BaseApp) RecordQuery(collectionModelOrIdentifier any) *dbx.SelectQuer
|
||||
|
||||
return nil
|
||||
default: // expects []RecordProxy slice
|
||||
records, err := resolveRecordAllHook(collection, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.Kind() != reflect.Ptr || rv.IsNil() {
|
||||
return errors.New("must be a pointer")
|
||||
@@ -118,11 +113,6 @@ func (app *BaseApp) RecordQuery(collectionModelOrIdentifier any) *dbx.SelectQuer
|
||||
return errors.New("must be a slice of RecordSetters")
|
||||
}
|
||||
|
||||
// create an empty slice
|
||||
if rv.IsNil() {
|
||||
rv.Set(reflect.MakeSlice(rv.Type(), 0, len(records)))
|
||||
}
|
||||
|
||||
et := rv.Type().Elem()
|
||||
|
||||
var isSliceOfPointers bool
|
||||
@@ -135,6 +125,16 @@ func (app *BaseApp) RecordQuery(collectionModelOrIdentifier any) *dbx.SelectQuer
|
||||
return op(sliceA)
|
||||
}
|
||||
|
||||
records, err := resolveRecordAllHook(collection, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create an empty slice
|
||||
if rv.IsNil() {
|
||||
rv.Set(reflect.MakeSlice(rv.Type(), 0, len(records)))
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
ev := reflect.New(et)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user