Skip to content

Bug: relations are lost when using sparse fieldset combined with include #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bart-degreed opened this issue Mar 16, 2020 · 0 comments · Fixed by #731
Closed

Bug: relations are lost when using sparse fieldset combined with include #708

bart-degreed opened this issue Mar 16, 2020 · 0 comments · Fixed by #731

Comments

@bart-degreed
Copy link
Contributor

When using sparse fieldsets, any related data that is included will be set to null.

For example, request to http://localhost:1479/api/v1/todoItems/375?include=owner returns:

{
  "links": {
    "self": "http://localhost:1479/api/v1/todoItems/375"
  },
  "data": {
    "type": "todoItems",
    "id": "375",
    "attributes": {
      "description": "Iusto harum voluptatem voluptatibus asperiores est iusto architecto eaque numquam.",
      "ordinal": 1,
      "guidProperty": "e0ca07d8-3db2-4060-a6d8-a910b0a1e672",
      "createdDate": "2019-11-08T06:59:38.612382",
      "achievedDate": null,
      "updatedDate": null,
      "calculatedValue": "calculated",
      "offsetDate": null
    },
    "relationships": {
      "owner": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/owner",
          "related": "http://localhost:1479/api/v1/todoItems/375/owner"
        },
        "data": {
          "type": "people",
          "id": "129"
        }
      },
      "assignee": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/assignee",
          "related": "http://localhost:1479/api/v1/todoItems/375/assignee"
        }
      },
      "oneToOnePerson": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/oneToOnePerson",
          "related": "http://localhost:1479/api/v1/todoItems/375/oneToOnePerson"
        }
      },
      "stakeHolders": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/stakeHolders",
          "related": "http://localhost:1479/api/v1/todoItems/375/stakeHolders"
        }
      },
      "collection": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/collection",
          "related": "http://localhost:1479/api/v1/todoItems/375/collection"
        }
      },
      "dependentOnTodo": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/dependentOnTodo",
          "related": "http://localhost:1479/api/v1/todoItems/375/dependentOnTodo"
        }
      },
      "parentTodo": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/parentTodo",
          "related": "http://localhost:1479/api/v1/todoItems/375/parentTodo"
        }
      },
      "childrenTodos": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/childrenTodos",
          "related": "http://localhost:1479/api/v1/todoItems/375/childrenTodos"
        }
      }
    },
    "links": {
      "self": "http://localhost:1479/api/v1/todoItems/375"
    }
  },
  "included": [
    {
      "type": "people",
      "id": "129",
      "attributes": {
        "firstName": "Tiffany",
        "lastName": "Kub",
        "age": 97
      },
      "relationships": {
        "todoItems": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/todoItems",
            "related": "http://localhost:1479/api/v1/people/129/todoItems"
          }
        },
        "assignedTodoItems": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/assignedTodoItems",
            "related": "http://localhost:1479/api/v1/people/129/assignedTodoItems"
          }
        },
        "todoCollections": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/todoCollections",
            "related": "http://localhost:1479/api/v1/people/129/todoCollections"
          }
        },
        "role": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/role",
            "related": "http://localhost:1479/api/v1/people/129/role"
          }
        },
        "oneToOneTodoItem": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/oneToOneTodoItem",
            "related": "http://localhost:1479/api/v1/people/129/oneToOneTodoItem"
          }
        },
        "stakeHolderTodoItem": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/stakeHolderTodoItem",
            "related": "http://localhost:1479/api/v1/people/129/stakeHolderTodoItem"
          }
        },
        "unIncludeableItem": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/unIncludeableItem",
            "related": "http://localhost:1479/api/v1/people/129/unIncludeableItem"
          }
        },
        "passport": {
          "links": {
            "self": "http://localhost:1479/api/v1/people/129/relationships/passport",
            "related": "http://localhost:1479/api/v1/people/129/passport"
          }
        }
      },
      "links": {
        "self": "http://localhost:1479/api/v1/people/129"
      }
    }
  ]
}

But request to http://localhost:1479/api/v1/todoItems/375?include=owner&fields=description returns:

{
  "links": {
    "self": "http://localhost:1479/api/v1/todoItems/375"
  },
  "data": {
    "type": "todoItems",
    "id": "375",
    "attributes": {
      "description": "Iusto harum voluptatem voluptatibus asperiores est iusto architecto eaque numquam."
    },
    "relationships": {
      "owner": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/owner",
          "related": "http://localhost:1479/api/v1/todoItems/375/owner"
        },
        "data": null
      },
      "assignee": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/assignee",
          "related": "http://localhost:1479/api/v1/todoItems/375/assignee"
        }
      },
      "oneToOnePerson": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/oneToOnePerson",
          "related": "http://localhost:1479/api/v1/todoItems/375/oneToOnePerson"
        }
      },
      "stakeHolders": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/stakeHolders",
          "related": "http://localhost:1479/api/v1/todoItems/375/stakeHolders"
        }
      },
      "collection": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/collection",
          "related": "http://localhost:1479/api/v1/todoItems/375/collection"
        }
      },
      "dependentOnTodo": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/dependentOnTodo",
          "related": "http://localhost:1479/api/v1/todoItems/375/dependentOnTodo"
        }
      },
      "parentTodo": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/parentTodo",
          "related": "http://localhost:1479/api/v1/todoItems/375/parentTodo"
        }
      },
      "childrenTodos": {
        "links": {
          "self": "http://localhost:1479/api/v1/todoItems/375/relationships/childrenTodos",
          "related": "http://localhost:1479/api/v1/todoItems/375/childrenTodos"
        }
      }
    },
    "links": {
      "self": "http://localhost:1479/api/v1/todoItems/375"
    }
  }
}

Note how data.relationships.owner.data has been set to null in the second response.

This was referenced May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant