-
-
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
adding and removing records from hasMany relationship broken. #2666
Comments
It works as expected in 1.0.0-beta.12 |
Thanks for opening an issue, investigating. |
Confirm this is a real bug, might take couple days to resolve, as it involves making smarter diffing of server/local state. Sorry about that :( |
We have the same bug here. For now, we just implemented a very basic (and ugly) workaround, by filtering items by ('isDeleted', false). But that's not awesome at all :( Hope to see some updates here soon ;) |
👍 |
@igorT any word on what might be causing this? Perhaps you can point me in the right direction. I would like to take a stab at this. |
This was slippery but I managed to create a test. I expected that |
@dwickern thanks for the test I am flopping around on the floor trying to figure out what is going on. It appears there are three arrays being managed for each hasMany relationship @igorT, @bmac what are your thoughts? Am I understanding this correctly? |
I am experiencing same bug. I don't know if it helps anyone, but the way in which the item is removed matters. If the record is removed using unloadRecord or destroyRecord I get the problem. If instead the record is removed using simply destroy(), the deleted record no longer appears the next time a record is added. |
Hi I have also come across this bug. Not sure how to create a failing test but have been able to create an example project that demonstrates it as well as JSBin. From my investigation bug seems to have been introduced with this PR Example repo Example JSBin Create a comment that The original comment comes back from dead, and the new comment is duplicated. |
@eccegordo a workaround is to put something like this in your controller
Here's your JSBin with the workaround applied: |
Seeing this too, on my end... |
+1 |
+1 here...if I destroy a record and then create a new one on the array, the destroyed record reappears. The Ember Inspector has the destroyed record in its |
ZN apply patch from https://github.com/emberjs/data/pull/2722/files about this issue: emberjs#2666 also be careful about emberjs#2795
can anyone tell me this problem is resolved in which version of the ember-data |
@dingchaoyan1983 I believe this issue was fixed in |
still experiencing this with ember data 2.10.. is it possible? |
i am also still experiencing this bug. i can imagine a lot of apps want to add and remove objects from their model's hasMany relations. |
@gregattra regression in 2.11, will be fixed shortly. @masciugo you absolutely sure you see this on 2.10? |
@runspired No, not sure anymore cause I upgraded to 2.11. Anyway, I was actually experiencing this which is going to be resolved soon, I guess |
I'm experiencing this. I was using 2.11, and I rolled back to 2.10. I'm still experiencing it there. I did a clean build to be sure. I'll continue to roll back and I'll comment with the most recent version that's working. I am wondering something, and I don't mean it as a criticism - presumably, this a pretty common use case, so I'd figure you'd have some testing built around it. Given that this bug made it into a release or two, I am wondering whether I am doing something that is against convention. Like these examples, I'm just trying to remove a record from a hasMany array, subsequently saving the parent record. First, I was using destroyRecord, but I also tried removeObject and popObject. |
I could reproduce the issue on 2.10.0, 2.9.0, and 2.8.0. The confines of my project don't permit rolling back further. In case you would like, I'll include a bit more detail:
I'm sorry I can't provide a code snippet or more detailed feedback. I am working at the moment, and can provide further feedback if it would help. Thanks! |
@bkl1989 what kind of error are you getting on save? A validation error triggering that results in |
Here's the code (please excuse my nested promise...) I've commented to indicate where the error occurs. Some of this isn't relevant, but I have left it in for context and so I don't accidentally modify something important.
And here is the error (caught in the .catch() of the enclosing promise chain)
Also, in a debugger breakpoint inside the .catch, moduleRecord.get('children') indicates that, though the current state of the array is length 0, the canonical state is still length 1 (I am not sure if this is relevant / helpful) Let me know if you'd like more detail. This is the best I can do for now without giving you access to the whole project :) |
@bkl1989 this seems unrelated, can you feed us more of the error caught? |
@runspired Sorry, the first line of my error stack got pruned off in the block formatting. I updated the comment. If it is unrelated, it's pretty similar. The removal of the child is the only modification to the module record at this point. The API call fires successfully and returns a payload which correctly represents the update. I'm not sure, after that, where the error occurs. |
The regression in 2.11 and 2.12 was fixed by #4791 and #4792 with the failing test #4790 added to cover this in the future. @bkl1989 your issue is not similar at all. The issue here was not an error thrown, the only correlation is that both relate to deleting a record in a has many. I suggest you ask in the Ember Community Slack and try to replicate this in a twiddle. |
@runspired We're experiencing this issue in Ember data 2.13.1 Is there a version you recommend rolling back to? |
@arian-kh I just ran into this issue with |
I am experiencing strange behavior in the latest version (1.0.0-beta.14.1) of ember data.
It appears that items removed from a hasMany collection reappear when adding new items.
Checkout the following jsbin http://jsbin.com/boluba/13
Remove an Item then add an item, the removed item will reappear. The strange thing is the item is not in the store when using the ember inspector.
The text was updated successfully, but these errors were encountered: