Skip to content

Duplicate Resource Objects Returned in Included #148

Closed
@jaredcnance

Description

@jaredcnance
var parent = new Parent {
    Name = "Alice"
};

var bob = new Person {
    Name = "Bob",
    Parent = parent
};

var bill = new Person {
    Name = "Bill",
    Parent = parent
};

context.Parents.Add(parent);
context.People.Add(bob);
context.People.Add(bill);
context.SaveChanges();
GET /api/v1/people?include=parent HTTP/1.1
Host: localhost:5000

returns duplicate entries for Alice in the included document:

{
  "data": [ ... ],
  "included": [
    {
      "type": "parents",
      "id": "3",
      "attributes": {
        "name": "Alice"
      },
      "relationships": {
        "people": {
          "links": {
            "self": "http://localhost:5000/api/v1/parents/3/relationships/people",
            "related": "http://localhost:5000/api/v1/parents/3/people"
          }
        }
      }
    },
    {
      "type": "parents",
      "id": "3",
      "attributes": {
        "name": "Alice"
      },
      "relationships": {
        "people": {
          "links": {
            "self": "http://localhost:5000/api/v1/parents/3/relationships/people",
            "related": "http://localhost:5000/api/v1/parents/3/people"
          }
        }
      }
    }
  ]
}

Investigation:

Thanks @grw300 for reporting this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions