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 7487701a
authored
Oct 01, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed(scopes/include) Fix scopes in conjunction with include all. Closes #4584
1 parent
31089c7d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
changelog.md
lib/model.js
test/unit/model/scope.test.js
changelog.md
View file @
7487701
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
+
mysql@2.9.0
+
mysql@2.9.0
-
coffee-script
-
coffee-script
-
[
FIXED
]
Add limit to
`findOne`
when using queries like
`{ id: { $gt ...`
[
#4416
](
https://github.com/sequelize/sequelize/issues/4416
)
-
[
FIXED
]
Add limit to
`findOne`
when using queries like
`{ id: { $gt ...`
[
#4416
](
https://github.com/sequelize/sequelize/issues/4416
)
-
[
FIXED
]
Include all with scopes
[
#4584
](
https://github.com/sequelize/sequelize/issues/4584
)
# 3.10.0
# 3.10.0
-
[
ADDED
]
support
`search_path`
for postgres with lots of schemas
[
#4534
](
https://github.com/sequelize/sequelize/pull/4534
)
-
[
ADDED
]
support
`search_path`
for postgres with lots of schemas
[
#4534
](
https://github.com/sequelize/sequelize/pull/4534
)
...
...
lib/model.js
View file @
7487701
...
@@ -2576,8 +2576,8 @@ Model.$injectScope = function (scope, options) {
...
@@ -2576,8 +2576,8 @@ Model.$injectScope = function (scope, options) {
// Reverse so we consider the latest include first.
// Reverse so we consider the latest include first.
// This is used if several scopes specify the same include - the last scope should take precendence
// This is used if several scopes specify the same include - the last scope should take precendence
scope
.
include
.
reverse
().
forEach
(
function
(
scopeInclude
)
{
scope
.
include
.
reverse
().
forEach
(
function
(
scopeInclude
)
{
if
(
!
_
.
any
(
options
.
include
,
function
matchesModelAndAlias
(
item
)
{
if
(
scopeInclude
.
all
||
!
_
.
any
(
options
.
include
,
function
matchesModelAndAlias
(
item
)
{
var
sameModel
=
item
.
model
.
name
===
scopeInclude
.
model
.
name
;
var
sameModel
=
item
.
model
&&
item
.
model
.
name
===
scopeInclude
.
model
.
name
;
if
(
sameModel
&&
item
.
as
)
{
if
(
sameModel
&&
item
.
as
)
{
return
item
.
as
===
scopeInclude
.
as
;
return
item
.
as
===
scopeInclude
.
as
;
...
...
test/unit/model/scope.test.js
View file @
7487701
...
@@ -315,5 +315,48 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -315,5 +315,48 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect
(
options
.
include
[
0
]).
to
.
deep
.
equal
({
model
:
User
,
where
:
{
something
:
true
}});
expect
(
options
.
include
[
0
]).
to
.
deep
.
equal
({
model
:
User
,
where
:
{
something
:
true
}});
expect
(
options
.
include
[
1
]).
to
.
deep
.
equal
({
model
:
Project
,
where
:
{
something
:
false
}});
expect
(
options
.
include
[
1
]).
to
.
deep
.
equal
({
model
:
Project
,
where
:
{
something
:
false
}});
});
});
describe
(
'include all'
,
function
()
{
it
(
'scope with all'
,
function
()
{
var
scope
=
{
include
:
[
{
all
:
true
}
]
};
var
options
=
{
include
:
[
{
model
:
User
,
where
:
{
something
:
true
}}
]
};
current
.
Model
.
$injectScope
(
scope
,
options
);
expect
(
options
.
include
).
to
.
have
.
length
(
2
);
expect
(
options
.
include
[
0
]).
to
.
deep
.
equal
({
model
:
User
,
where
:
{
something
:
true
}});
expect
(
options
.
include
[
1
]).
to
.
deep
.
equal
({
all
:
true
});
});
it
(
'options with all'
,
function
()
{
var
scope
=
{
include
:
[
{
model
:
User
,
where
:
{
something
:
true
}}
]
};
var
options
=
{
include
:
[
{
all
:
true
}
]
};
current
.
Model
.
$injectScope
(
scope
,
options
);
expect
(
options
.
include
).
to
.
have
.
length
(
2
);
expect
(
options
.
include
[
0
]).
to
.
deep
.
equal
({
all
:
true
});
expect
(
options
.
include
[
1
]).
to
.
deep
.
equal
({
model
:
User
,
where
:
{
something
:
true
}});
});
});
});
});
});
});
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