fix nil pointer panic

This commit is contained in:
Sam Woodard 2015-10-12 11:05:06 -07:00
parent d9645f7f7e
commit fb2e4b68ce
1 changed files with 5 additions and 1 deletions

View File

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