ember-data-model-fragments icon indicating copy to clipboard operation
ember-data-model-fragments copied to clipboard

[Model Fragments - 5.0.0-beta.0] Fragment Array returned in changedAttributes of record

Open pragatheeswarans opened this issue 5 years ago • 3 comments

Summary record.changedAttributes() in the adapter is returning the fragment array of the model which was not returned in the older version say 4.0.0

Details

Let's assume a model models/filter.js as

import Model, { attr } from '@ember-data/model';
import { fragmentArray } from 'ember-data-model-fragments/attributes';

export default Model.extend({
  name: attr('string'),
  conditions: fragmentArray('condition')
})

and the models/condition.js as

import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';

export default Fragment.extend({
  field: attr('string'),
  predicate: attr('string'),
  value: attr()
});

When I try to create a filter record like this

   const filter = this.store.createRecord('filter');
   filter.set('name', 'Test');
   filter.set('conditions', []);
   filter.save();

In the adapter we get the changedAttributes by calling record.changedAttributes() and create the payload based on this method's response. And for the fragments we used to check the hasDirtyAttributes property in the fragment to check if this needs to be in the payload or not.

Up until the version 4.0.0 the record.changedAttributes() did not return the conditions property in the object. But after trying out the 5.0.0-beta.0 version, I see that the conditions attribute is returned in the record.changedAttributes() which is breaking our test cases. Is this the intentional behavior going forward?

pragatheeswarans avatar Jun 02 '20 04:06 pragatheeswarans

As far as I know this was a bug that the fragment was not returned in the changedAttributes. I'm pretty sure it was in earlier versions 😉

VincentMolinie avatar Jun 03 '20 15:06 VincentMolinie

Is there any tentative release date for the stable version?

pragatheeswaranshf avatar Jul 16 '20 07:07 pragatheeswaranshf

there seems to be a fair amount of issues in the beta so it will probably be some time before a stable version

jakesjews avatar Jul 16 '20 16:07 jakesjews