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

Commit d65cc7bc by Mirko Jotic Committed by Sushant

fix(reload): instance.changed() remains unaffected (#9615)

1 parent c05a0342
...@@ -3384,6 +3384,9 @@ class Model { ...@@ -3384,6 +3384,9 @@ class Model {
if (options.reset) { if (options.reset) {
this.dataValues = {}; this.dataValues = {};
for (const key in values) {
this.changed(key, false);
}
} }
// If raw, and we're not dealing with includes or special attributes, just set it straight on the dataValues object // If raw, and we're not dealing with includes or special attributes, just set it straight on the dataValues object
...@@ -3498,7 +3501,6 @@ class Model { ...@@ -3498,7 +3501,6 @@ class Model {
} }
} }
} }
return this; return this;
} }
......
...@@ -35,6 +35,18 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -35,6 +35,18 @@ describe(Support.getTestDialectTeaser('Model'), () => {
})); }));
}); });
it('changed should be false after reload', function() {
return this.Account.create({ ownerId: 2, name: 'foo' })
.then(account => {
account.name = 'bar';
expect(account.changed()[0]).to.equal('name');
return account.reload();
})
.then(account => {
expect(account.changed()).to.equal(false);
});
});
it('should ignore undefined values without throwing not null validation', function() { it('should ignore undefined values without throwing not null validation', function() {
const ownerId = 2; const ownerId = 2;
return this.Account.create({ return this.Account.create({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!