不要怂,就是干,撸起袖子干!

Commit 780f7c00 by maayany_h Committed by Sushant

change(model): setDataValue should not mark null to null as changed (#9347)

1 parent 21ee1c87
...@@ -3213,7 +3213,7 @@ class Model { ...@@ -3213,7 +3213,7 @@ class Model {
*/ */
setDataValue(key, value) { setDataValue(key, value) {
const originalValue = this._previousDataValues[key]; const originalValue = this._previousDataValues[key];
if (!Utils.isPrimitive(value) || value !== originalValue) { if ((!Utils.isPrimitive(value) && value !== null) || value !== originalValue) {
this.changed(key, true); this.changed(key, true);
} }
......
...@@ -170,5 +170,22 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -170,5 +170,22 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
expect(user.changed(attr), `${attr} is not changed`).to.equal(false); expect(user.changed(attr), `${attr} is not changed`).to.equal(false);
} }
}); });
describe('setDataValue', () => {
it('should return falsy for unchanged primitive', function() {
const user = this.User.build({
name: 'a',
meta: null
}, {
isNewRecord: false,
raw: true
});
user.setDataValue('name', 'a');
user.setDataValue('meta', null);
expect(user.changed('name')).to.equal(false);
expect(user.changed('meta')).to.equal(false);
});
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!