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

Commit 15354c7b by Patrick Geyer Committed by Simon Schick

fix(querying): treat having the same as where when using scopes (#10884)

1 parent 1b8c3898
Showing with 31 additions and 1 deletions
......@@ -797,7 +797,7 @@ class Model {
if (Array.isArray(objValue) && Array.isArray(srcValue)) {
return _.union(objValue, srcValue);
}
if (key === 'where') {
if (key === 'where' || key === 'having') {
if (srcValue instanceof Utils.SequelizeMethod) {
srcValue = { [Op.and]: srcValue };
}
......
......@@ -372,6 +372,36 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
it('should be able to merge scope and having', () => {
Sequelize.Model._scope = {
having: {
something: true,
somethingElse: 42
},
limit: 15,
offset: 3
};
const options = {
having: {
something: false
},
limit: 9
};
Sequelize.Model._injectScope(options);
expect(options).to.deep.equal({
having: {
something: false,
somethingElse: 42
},
limit: 9,
offset: 3
});
});
it('should be able to merge scopes with the same include', () => {
Sequelize.Model._scope = {
include: [
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!