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

Commit be8760db by Lawton Spelliscy Committed by Sushant

fix(addScope): only throw when defaultScope is defined (#9703)

1 parent 532286f3
Showing with 9 additions and 1 deletions
......@@ -1423,7 +1423,7 @@ class Model {
override: false
}, options);
if ((name === 'defaultScope' || name in this.options.scopes) && options.override === false) {
if ((name === 'defaultScope' && Object.keys(this.options.defaultScope).length > 0 || name in this.options.scopes) && options.override === false) {
throw new Error('The scope ' + name + ' already exists. Pass { override: true } as options to silence this error');
}
......
......@@ -294,6 +294,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}).to.throw('The scope defaultScope already exists. Pass { override: true } as options to silence this error');
});
it('should not warn if default scope is not defined', () => {
const Model = current.define('model');
expect(() => {
Model.addScope('defaultScope', {});
}).not.to.throw();
});
it('allows me to override a default scope', () => {
Company.addScope('defaultScope', {
include: [Project]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!