forked from Mirrors/jsonapi
fix nil pointer panic
This commit is contained in:
parent
d9645f7f7e
commit
fb2e4b68ce
|
@ -223,9 +223,9 @@ func visitModelNode(model interface{}, sideload bool) (*Node, []*Node, error) {
|
|||
|
||||
if isSlice {
|
||||
relationship, incl, err := visitModelNodeRelationships(args[1], fieldValue, sideload)
|
||||
d := relationship.Data
|
||||
|
||||
if err == nil {
|
||||
d := relationship.Data
|
||||
if sideload {
|
||||
included = append(included, incl...)
|
||||
var shallowNodes []*Node
|
||||
|
@ -287,6 +287,10 @@ func visitModelNodeRelationships(relationName string, models reflect.Value, side
|
|||
included = make([]*Node, 0)
|
||||
}
|
||||
|
||||
if models.Len() == 0 {
|
||||
nodes = make([]*Node, 0)
|
||||
}
|
||||
|
||||
for i := 0; i < models.Len(); i++ {
|
||||
node, incl, err := visitModelNode(models.Index(i).Interface(), sideload)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue