Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit be8760db
authored
Jul 22, 2018
by
Lawton Spelliscy
Committed by
Sushant
Jul 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(addScope): only throw when defaultScope is defined (#9703)
1 parent
532286f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
lib/model.js
test/unit/model/scope.test.js
lib/model.js
View file @
be8760d
...
...
@@ -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'
);
}
...
...
test/unit/model/scope.test.js
View file @
be8760d
...
...
@@ -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
]
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment