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

Commit ba49c7f0 by Timothée Alby Committed by Sushant

fix(model/aggregate): inject scope before conforming options (#9190)

1 parent 4daf5224
......@@ -1779,8 +1779,8 @@ class Model {
options = Utils.cloneDeep(options);
options = _.defaults(options, { attributes: [] });
this._conformOptions(options, this);
this._injectScope(options);
this._conformOptions(options, this);
if (options.include) {
this._expandIncludeAll(options);
......
......@@ -45,6 +45,26 @@ describe(Support.getTestDialectTeaser('Model'), () => {
priority: 1
}
}]
},
withIncludeFunction: () => {
return {
include: [{
model: this.Child,
where: {
priority: 1
}
}]
};
},
withIncludeFunctionAndStringAssociation: () => {
return {
include: [{
association: 'Children',
where: {
priority: 1
}
}]
};
}
}
});
......@@ -100,6 +120,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to use where on include', function() {
return expect(this.ScopeMe.scope('withInclude').count()).to.eventually.equal(1);
});
it('should be able to use include with function scope', function() {
return expect(this.ScopeMe.scope('withIncludeFunction').count()).to.eventually.equal(1);
});
it('should be able to use include with function scope and string association', function() {
return expect(this.ScopeMe.scope('withIncludeFunctionAndStringAssociation').count()).to.eventually.equal(1);
});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!