adopted-ember-addons / ember-data-model-fragments

Ember Data addon to support nested JSON documents
MIT License
370 stars 114 forks source link

empty fragment array not sent to server #323

Open aandis opened 5 years ago

aandis commented 5 years ago

Given


// app/models/person.js
export default Model.extend({
  name: attr('string'),
  addresses : fragmentArray('address'),
});

// app/models/address.js
export default Fragment.extend({
  street  : attr('string'),
  country : attr('string')
});

If person looks like -

{
  "name": "John",
  "addresses": [
    { "street": "test", "country": "test" }
  ]
}

and I delete the address object from person in my app with

this.get('model').get('addresses').removeAt(0)

and try to save the model, the json posted is -

{ "name": "John" }

I would expect the following json to be posted -

{ "name": "John", "addresses": [] }

Is this expected behavior?

aandis commented 5 years ago
ember-data-model-fragments@3.3.0
ember-data@3.4.4
aandis commented 5 years ago

ping.

jakesjews commented 5 years ago

hello @aandis I don't think the behavior has been explicitly defined but I would accept a PR to fix it.