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 15354c7b
authored
May 03, 2019
by
Patrick Geyer
Committed by
Simon Schick
May 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(querying): treat having the same as where when using scopes (#10884)
1 parent
1b8c3898
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
lib/model.js
test/unit/model/scope.test.js
lib/model.js
View file @
15354c7
...
@@ -797,7 +797,7 @@ class Model {
...
@@ -797,7 +797,7 @@ class Model {
if
(
Array
.
isArray
(
objValue
)
&&
Array
.
isArray
(
srcValue
))
{
if
(
Array
.
isArray
(
objValue
)
&&
Array
.
isArray
(
srcValue
))
{
return
_
.
union
(
objValue
,
srcValue
);
return
_
.
union
(
objValue
,
srcValue
);
}
}
if
(
key
===
'where'
)
{
if
(
key
===
'where'
||
key
===
'having'
)
{
if
(
srcValue
instanceof
Utils
.
SequelizeMethod
)
{
if
(
srcValue
instanceof
Utils
.
SequelizeMethod
)
{
srcValue
=
{
[
Op
.
and
]:
srcValue
};
srcValue
=
{
[
Op
.
and
]:
srcValue
};
}
}
...
...
test/unit/model/scope.test.js
View file @
15354c7
...
@@ -372,6 +372,36 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -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'
,
()
=>
{
it
(
'should be able to merge scopes with the same include'
,
()
=>
{
Sequelize
.
Model
.
_scope
=
{
Sequelize
.
Model
.
_scope
=
{
include
:
[
include
:
[
...
...
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