-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
pushPayload does not change hasMany relationship when going to empty state #4804
Comments
@danielspaniel https://ember-twiddle.com/53d305379774c4756d576107c98ae6d4?openFiles=routes.application.js%2C In the above twiddle you can comment / uncomment line 48 (ie the There are two changes as compared to your original twiddle.
Please let me know if I have misunderstood the issue your twiddle aimed to highlight, but I believe the core error in the above was in the payload and not an ember data bug. |
The issue with the first twiddle is that the relationship is being added as "dirty state", it won't be cleared because no save attempt has been made (so obviously a server update would not know about it). |
The reason I flag this as a bug is because even in a dirty state if you pushPayload with values for the hasMany then the relationship will update itself to add those new rows. Here is a gist to show what I mean: But I know what your going to say ... Hey Dan, you see, the start state is empty, you set some things, then pushPayload tries to clear them, but since this hasMany does not "know" about those 2 new things, it can't remove them. 2 flaws in that argument. Also, the belongsTo relationship is happy to clear any "dirty state" ( new model ) you set when you pushPayload. So, it seems like pushPayload is just not quite 100% clear on it's mission for what to do with hasMany because usually pushPayload just sets the state to what you pushed, no matter what state your in .. no questions asked, and resets the state of the model to root.loaded.saved. It is a way to update the model immediately to a new state, and call it saved. Which works for 95% of cases except the hasMany. |
Any news here? |
@Exelord mostly fixed. There's one case for "current vs canonical" where we get it wrong that has not been fixed which is this test PR: #5269 and is the case mentioned by @danielspaniel in his last comment. Once the |
I believe #4852 improves this situation, once that lands I will add more tests and hopefully this issue will be resolved :) |
I ran into the same issue with ember-data Version 3.8: empty relationship arrays in the payload didn't clear the relationship. What is the state of this issue? |
I have the same issue |
@Dirk-27 the state of this issue is there is nothing more we can do for While not explicitly enabled by the new cache design in emberjs/rfcs#854 once |
Also closing this as at this point this request is more about relationship-rollback than it is about updating the state. The store forking behavior introduced in emberjs/rfcs#854 allows applications to better choose whether to display remote or mutated state as desired, so rollback and this issue are dead artifacts of a previous era of APIs. |
I have a model which hasMany things, then I pushPayload with data that says .. I have no things anymore. Ember data ignores that and keeps the hasMany things.
The key activities are that:
Here is a twiddle to show the problem:
https://ember-twiddle.com/26204b7fa7fc185dde464418cd33df95?openFiles=routes.application.js%2C
The text was updated successfully, but these errors were encountered: