You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is happening is that it appears that reloading a record with a hasMany association does not actually update the record's associations. Even forcing the hasMany using the hasMany('ref').push([]) does not force any associations to go away. The only way to make all the associations revert is to completely unload the records and reload them.
Only the last method of reloading actually works at reverting the hasMany('person') relationship:
reload(contract, people){
contract.reload();
people.update();
},
rollback(contract){
contract.rollbackAttributes();
},
force(contract){
contract.hasMany('people').push([]);
},
allTheThings(model){
model.contract.unloadRecord();
this.store.unloadAll('people');
this.refresh(); // reload the route which loads the records again
}
With models that are interconnected i essentially have to wipe all records in the store to effectively clear a canceled update of a record.
The text was updated successfully, but these errors were encountered:
when we receive new data for a relationship we do update the canonical state correctly, however, we don't blow away any local changes when the local change adds a new (unsaved) record. All other local changes will be blown away.
If you find you are retaining local changes that aren't new records, then please open a bug report! However if instead you find you are retaining local changes to records that are in a new state but which you thought you'd saved then likely the save action isn't being performed correctly. Typically this happens when sideposting relationships, and in this case using identifiers will fix this issue for you.
Closing as I don't think there's bug for us to fix here given the test coverage we have at this point, though maybe there was at the time this was opened.
First of all here is the twiddle:
https://ember-twiddle.com/9d09b6673cb026a0303bab0d1bbc6f0a?openFiles=routes.index.js%2C
What is happening is that it appears that reloading a record with a hasMany association does not actually update the record's associations. Even forcing the hasMany using the
hasMany('ref').push([])
does not force any associations to go away. The only way to make all the associations revert is to completely unload the records and reload them.Given the following models:
Only the last method of reloading actually works at reverting the
hasMany('person')
relationship:With models that are interconnected i essentially have to wipe all records in the store to effectively clear a canceled update of a record.
The text was updated successfully, but these errors were encountered: