Skip to content
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

Fix fetch hasMany using links when parent & child records are already loaded #5274

Closed
mattraydub opened this issue Dec 12, 2017 · 4 comments · Fixed by #5410
Closed

Fix fetch hasMany using links when parent & child records are already loaded #5274

mattraydub opened this issue Dec 12, 2017 · 4 comments · Fixed by #5410

Comments

@mattraydub
Copy link

Given a Parent model with "children" (hasMany) and Child model with "parent" (belongsTo) and proper inverses setup, when loading (store.findRecord) the Parent record, then loading one of the Child records (store.findRecord), then accessing parent.get('children') only returns the 1 previously fetch Child record instead of using the links, and fetching the entire relationship from the server.

Looks like the issue exists somewhere in the loading of the child payload. Since the payload includes a reference to its parent relationship, the store notices it already has that parent and updates the inverse relationship "children" with this 1 record in the store._relationshipsPayloads. So before fetching its children the parent already knows about this child in its relationshipsPayload. Not sure if this is necessary since it really needs to use the link to fetch the rest of the children from the server, in order to have the proper records loaded into that relationship.

Will be posting my breaking test shortly.

This is similar to #5209 but not exactly the same.

mattraydub pushed a commit to swarmbox/data that referenced this issue Dec 12, 2017
@mattraydub
Copy link
Author

This was fixed by PR #5257

mattraydub pushed a commit to swarmbox/data that referenced this issue Dec 15, 2017
mattraydub added a commit to swarmbox/data that referenced this issue Dec 15, 2017
+ Rollback Relationships (cherry picked from commit 42e6e56)
+ [BUGFIX] Fix store.createRecord with belongsTo when model has @each observer (cherry picked from commit c257bbb)
+ [BUGFIX emberjs#5274] fixes breaking test for bug emberjs#5274
mattraydub added a commit to swarmbox/data that referenced this issue Dec 15, 2017
+ Rollback Relationships (cherry picked from commit 42e6e56)
+ [BUGFIX] Fix store.createRecord with belongsTo when model has @each observer (cherry picked from commit c257bbb)
+ [BUGFIX emberjs#5274] fixes breaking test for bug emberjs#5274
+ Move initialize-store-service.js out of the instance-initializers directory. (cherry picked from commit f3e1e32) Fixes emberjs#5118
@jamesarosen
Copy link

@mattraydub you said this was fixed by #5257, but that hasn't been merged. Do you mean another PR? Or should we reopen this?

@mattraydub
Copy link
Author

mattraydub commented Feb 7, 2018

@jamesarosen This issue presents a problem with a breaking test. The PR #5257 fixes this problem, so I closed so that no one continues to try to fix it. Not sure if they will ever merge that PR, but I cherry-picked it into the version I am using. I guess we could reopen, but just wanted to explain my point-of-view.

@psbanka
Copy link

psbanka commented Feb 7, 2018

@mattraydub - I would advocate for re-opening this ticket so that it has visibility to the greater team. Clearly we don't want to be running on a forked version of ember-data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants