Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
esp0 opened this Issue · 2 comments

4 participants

@esp0

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:

http://jsfiddle.net/Vz3E6/2/

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.

@elliterate

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
Collaborator

Updated fiddle with latest ember & ember-data, this seems to work now: see http://jsfiddle.net/Sly7/Z8dCm/

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.