Skip to content

Associated child records disappearing after reverting relationship to original value #465

esp0 opened this Issue Nov 8, 2012 · 2 comments

4 participants

esp0 commented Nov 8, 2012

After changing an association and then changing it back (a couple of times), the association is lost.

    var newCar = MyApp.CarModel.find('hummer');
    MyApp.Person.find('wycats').set('car', newCar);
    var oldCar = MyApp.CarModel.find('toyota');
    MyApp.Person.find('wycats').set('car', oldCar);

Not very easy to explain, but very easy to see in this jsfiddle:

Click the buttons in this order and you will see that the association is lost: 1, 2, 1, 2

I am using ember-latest and ember-data-latest.


This is definitely an existing bug. When Ember Data detects that a change to a child will effectively undo an earlier, as-yet-uncommitted change, it rolls back the parents, but fails to actually roll back the child and (because of some messy internal details) winds up setting it to null instead.

We have an open pull request introducing hasOne associations which happens to fix it with this line, as proven by this test.

sly7-7 commented Apr 19, 2013

Updated fiddle with latest ember & ember-data, this seems to work now: see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.