Skip to content

Duplicate Resource Objects Returned in Included #148

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
jaredcnance opened this issue Aug 9, 2017 · 0 comments · Fixed by #149
Closed

Duplicate Resource Objects Returned in Included #148

jaredcnance opened this issue Aug 9, 2017 · 0 comments · Fixed by #149
Labels

Comments

@jaredcnance
Copy link
Contributor

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!

@jaredcnance jaredcnance added the bug label Aug 9, 2017
jaredcnance added a commit that referenced this issue Aug 10, 2017
fix(DocumentBuilder): do not include entities twice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant