Another instance of helper slices in eager code

- Another instance of helper slice types seeping in. Convert the slice
  when it's found as part of a singular's R struct.
- Fix #158
This commit is contained in:
Aaron L 2017-06-08 20:46:15 -07:00
parent 2168a70c4f
commit 9107c9dea1

View file

@ -206,9 +206,16 @@ func (l loadRelationshipState) loadRelationshipsRecurse(depth int, obj reflect.V
} }
bkind := kindStruct bkind := kindStruct
if reflect.Indirect(loadedObject).Kind() != reflect.Struct { if derefed := reflect.Indirect(loadedObject); derefed.Kind() != reflect.Struct {
bkind = kindPtrSliceStruct bkind = kindPtrSliceStruct
loadedObject = loadedObject.Addr()
// Convert away any helper slice types
// elemType is *elem (from []*elem or helperSliceType)
// sliceType is *[]*elem
elemType := derefed.Type().Elem()
sliceType := reflect.PtrTo(reflect.SliceOf(elemType))
loadedObject = loadedObject.Addr().Convert(sliceType)
} }
return l.loadRelationships(depth+1, loadedObject.Interface(), bkind) return l.loadRelationships(depth+1, loadedObject.Interface(), bkind)
} }