Reputation: 385
I'm trying to remove a field from a changeset (or set it to undefined) so that when the changeset is applied the field will be removed (or set to undefined) on the model. How can this be achieved?
Cheers
Upvotes: 0
Views: 598
Reputation: 6338
ember-changeset does not support setting a value to undefined
. Calling changeset.set()
with undefined
as value does not set the value.
let obj = Ember.Object.create({
foo: 'a',
bar: 'b'
});
let changeset = new Changeset(user);
changeset.set('foo', null);
changeset.set('bar', undefined);
changeset.get('bar'); // b
changeset.get('change'); // { foo: null }
I'm quite surprised about that myself. Since it's not expected behavior and it does not seem to be documented, I think it should be considered a bug and get fixed.
I've opened a pull request for ember-changeset adding a failing test: https://github.com/DockYard/ember-changeset/pull/191
Upvotes: 1