From 9b8432d9d9dd4b1b17f313228b9c64fa7321260b Mon Sep 17 00:00:00 2001 From: Sam Woodard Date: Fri, 10 Jul 2015 14:31:26 -0700 Subject: [PATCH] bug fix: was missing objects in sideload --- request_test.go | 4 ++++ response.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/request_test.go b/request_test.go index cf7eef2..69df26a 100644 --- a/request_test.go +++ b/request_test.go @@ -133,6 +133,10 @@ func TestUnmarshalNestedRelationshipsSideloaded(t *testing.T) { if len(out.CurrentPost.Comments) != 2 { t.Fatalf("Wrong number of comments") } + + if out.CurrentPost.Comments[0].Body != "foo" { + t.Fatalf("Comment body not set") + } } func unmarshalSamplePayload() (*Blog, error) { diff --git a/response.go b/response.go index 8f3f3ff..4229d74 100644 --- a/response.go +++ b/response.go @@ -178,10 +178,10 @@ func visitModelNode(model interface{}, sideload bool) (*Node, []*Node, error) { return false } } else { - relationship, _, err := visitModelNode(fieldValue.Interface(), sideload) + relationship, inc, err := visitModelNode(fieldValue.Interface(), sideload) if err == nil { if sideload { - included = append(included, relationship) + included = append(included, inc...) node.Relationships[args[1]] = &RelationshipOneNode{Data: toShallowNode(relationship)} } else { node.Relationships[args[1]] = &RelationshipOneNode{Data: relationship}