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

Commit 1823f5d0 by Sushant Committed by GitHub

fix: destroy with paranoid ignores operators (#8860)

1 parent bb2d0bd9
Showing with 28 additions and 1 deletions
...@@ -2538,7 +2538,7 @@ class Model { ...@@ -2538,7 +2538,7 @@ class Model {
where[field] = deletedAtAttribute.hasOwnProperty('defaultValue') ? deletedAtAttribute.defaultValue : null; where[field] = deletedAtAttribute.hasOwnProperty('defaultValue') ? deletedAtAttribute.defaultValue : null;
attrValueHash[field] = Utils.now(this.sequelize.options.dialect); attrValueHash[field] = Utils.now(this.sequelize.options.dialect);
return this.QueryInterface.bulkUpdate(this.getTableName(options), attrValueHash, _.defaults(where, options.where), options, this.rawAttributes); return this.QueryInterface.bulkUpdate(this.getTableName(options), attrValueHash, Object.assign(where, options.where), options, this.rawAttributes);
} else { } else {
return this.QueryInterface.bulkDelete(this.getTableName(options), options.where, options, this); return this.QueryInterface.bulkDelete(this.getTableName(options), options.where, options, this);
} }
......
...@@ -1649,6 +1649,33 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -1649,6 +1649,33 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
}); });
}); });
it('should work if model is paranoid and only operator in where clause is a Symbol', function() {
const User = this.sequelize.define('User', {
username: Sequelize.STRING
}, {
paranoid: true
});
return User.sync({ force: true})
.then(() => User.create({ username: 'foo' }))
.then(() => User.create({ username: 'bar' }))
.then(() => {
return User.destroy({
where: {
[Sequelize.Op.or]: [
{ username: 'bar' },
{ username: 'baz' }
]
}
});
})
.then(() => User.findAll())
.then(users => {
expect(users).to.have.length(1);
expect(users[0].get('username')).to.equal('foo');
});
});
}); });
describe('restore', () => { describe('restore', () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!