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

Commit 217ba180 by Jan Aagaard Meier

bug(scopes) Mark unscoped model as .scoped to prevent injection of default scope…

… on includes. Closes #4663
1 parent 7f5a251b
# NEXT
- [FIXED] Mark unscoped model as `.scoped`, to prevent injection of default scope on includes [#4663](https://github.com/sequelize/sequelize/issues/4663)
# 3.12.1
- [FIXED] Mark postgres connection as invalid if the connection is reset [#4661](https://github.com/sequelize/sequelize/pull/4661)
- [FIXED] Remove usage of "limit" in cases where it's unnecessary, which fixes some of the cases mentioned in [#4404] (https://github.com/sequelize/sequelize/issues/4404)
......
......@@ -1164,6 +1164,7 @@ Model.prototype.scope = function(option) {
, scopeName;
self.$scope = {};
self.scoped = true;
if (!option) {
return self;
......@@ -1216,8 +1217,6 @@ Model.prototype.scope = function(option) {
}
});
self.scoped = true;
return self;
};
......
......@@ -80,6 +80,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('should be able to unscope', function () {
expect(Company.scope(null).$scope).to.be.empty;
expect(Company.unscoped().$scope).to.be.empty;
// Yes, being unscoped is also a scope - this prevents inject defaultScope, when including a scoped model, see #4663
expect(Company.unscoped().scoped).to.be.ok;
});
it('should be able to merge scopes', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!