Skip to content

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

@pragatheeswarans

Description

@pragatheeswarans

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions