Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pragatheeswarans opened this issue Jun 2, 2020 · 3 comments

Comments

@pragatheeswarans
Copy link

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?

@VincentMolinie
Copy link
Contributor

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 😉

@pragatheeswaranshf
Copy link

Is there any tentative release date for the stable version?

@jakesjews
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants