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

Commit 5a4d2600 by Sushant Committed by GitHub

fix(model.reload): ignore options.where and always use this.where() (#12211)

1 parent 6fb74c8a
......@@ -4049,8 +4049,9 @@ class Model {
* @returns {Promise<Model>}
*/
async reload(options) {
options = Utils.defaults({}, options, {
where: this.where(),
options = Utils.defaults({
where: this.where()
}, options, {
include: this._options.include || null
});
......
......@@ -91,6 +91,20 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
});
it('should use default internal where', async function() {
const user = await this.User.create({ username: 'Balak Bukhara' });
const anotherUser = await this.User.create({ username: 'John Smith' });
const primaryKey = user.get('id');
await user.reload();
expect(user.get('id')).to.equal(primaryKey);
// options.where should be ignored
await user.reload({ where: { id: anotherUser.get('id') } });
expect(user.get('id')).to.equal(primaryKey).and.not.equal(anotherUser.get('id'));
});
it('should update the values on all references to the DAO', function() {
return this.User.create({ username: 'John Doe' }).then(originalUser => {
return this.User.findByPk(originalUser.id).then(updater => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!