Skip to content

Duplicate resource object in compound document #1202

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
hut8 opened this issue Sep 25, 2015 · 2 comments · Fixed by #1239
Closed

Duplicate resource object in compound document #1202

hut8 opened this issue Sep 25, 2015 · 2 comments · Fixed by #1239

Comments

@hut8
Copy link
Contributor

hut8 commented Sep 25, 2015

There's a bug here (unless I'm reading something wrong) and I can't find an open issue that describes this. Please forgive me if this is a duplicate.

Reproduction set-up

Making a compound document using include. It contains an Organization, which has_many :people, and Person belongs_to :organization (there are many other cases that would reproduce this, I think). I have an organization with ID 1, and some people belonging to that organization. The document would have an array of people in the included key.

The bug

The JSON API spec says:

A compound document MUST NOT include more than one resource object for each type and id pair.

The compound document consists of a document containing both data and included top-level keys. The data is just the Organization with ID 1, which has relationships which has people which has data, which is an array of Person objects with just type (==people) and id.

In the included top-level key, you have the Person entities related to the organization. But also, the Organization appears here. So you have two resource objects in the same compound document with the same type (organization) and ID (1). That's a bug, right?

@hut8
Copy link
Contributor Author

hut8 commented Sep 25, 2015

Also it's only going to happen with ** specified for include, or equivalent.

@beauby
Copy link
Contributor

beauby commented Sep 27, 2015

You are very right, thanks for pointing that out @hut8. I'll provide a fixing PR in the coming hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment