Skip to content

Deserialization does not work on repeated included relationships #173

@rfblue2

Description

@rfblue2

If there are relationships that share resources, and are included only once each (see the example below - there are only two books but one is both a "selling" and a "favorite") when they are deserialized the second instance of the repeated relationship is not properly included (it just places null)

{
    "data": {
        "type": "user",
        "id": "5ad2601522c6f6733408ae1f",
        "attributes": {...},
        "relationships": {
            "favorite": {
                "data": [
                    {
                        "type": "book",
                        "id": "5aca58621d13177065279691"
                    }
                ]
            },
            "selling": {
                "data": [
                    {
                        "type": "book",
                        "id": "5ac8dd784f904b5a281aa061"
                    },
                    {
                        "type": "book",
                        "id": "5aca58621d13177065279691"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "type": "book",
            "id": "5aca58621d13177065279691",
            "attributes": {...},
        },
        {
            "type": "book",
            "id": "5ac8dd784f904b5a281aa061",
            "attributes": {...}
        }
    ]
}

When deserialized, this returns

{
  ...
  "id": "5ad2601522c6f6733408ae1f",
  "selling": [
    {
      ...
      "id": "5ac8dd784f904b5a281aa061"
    },
    null <-- Relationship was included but presumably used up for something else!
  ],
  "favorite": [
    {
      ...
      "id": "5aca58621d13177065279691"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions