forked from Mirrors/jsonapi
bug fix: was missing objects in sideload
This commit is contained in:
parent
ffcbb660c3
commit
9b8432d9d9
|
@ -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) {
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue