Associated Ember-related child records disappear after changes are returned to the association

After changing the association and its subsequent change (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/

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

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

EDIT: I created a copy of this question as a problem in the tracker problem with ember data: # 465

+4
source share
1 answer

This is a bug in the latest version of Ember Data. When Ember Data discovers that the change for the child effectively cancels the earlier, as yet unfixed change, it rolls back the parents, but does not actually allow the child to be discarded and (due to some dirty internal details) completes the setting instead of null.

We have an open selection request containing the hasOne association , which, as it turns out, corrects it using this line , as this test proved.

+1
source

Source: https://habr.com/ru/post/1444579/


All Articles