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 64d13eaf
authored
Jan 16, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat/fix(include): provide through.scope support for includes
1 parent
cbc54303
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletions
lib/dialects/abstract/query-generator.js
lib/model.js
test/associations/scope.test.js
lib/dialects/abstract/query-generator.js
View file @
64d13ea
...
...
@@ -1001,7 +1001,7 @@ module.exports = (function() {
// Generate a wrapped join so that the through table join can be dependent on the target join
joinQueryItem
+=
joinType
+
'('
;
joinQueryItem
+=
self
.
quoteTable
(
throughTable
,
throughAs
);
joinQueryItem
+=
joinType
+
self
.
quoteTable
(
table
,
as
)
+
' ON '
;
joinQueryItem
+=
' INNER JOIN '
+
self
.
quoteTable
(
table
,
as
)
+
' ON '
;
joinQueryItem
+=
targetJoinOn
;
if
(
throughWhere
)
{
...
...
lib/model.js
View file @
64d13ea
...
...
@@ -2032,6 +2032,11 @@ module.exports = (function() {
_pseudo
:
true
});
if
(
through
.
scope
)
{
include
.
through
.
where
=
include
.
through
.
where
?
new
Utils
.
and
([
include
.
through
.
where
,
through
.
scope
])
:
through
.
scope
;
}
include
.
include
.
push
(
include
.
through
);
tableNames
[
through
.
tableName
]
=
true
;
}
...
...
test/associations/scope.test.js
View file @
64d13ea
...
...
@@ -412,6 +412,37 @@ describe(Support.getTestDialectTeaser('associations'), function() {
expect
(
questionTags
.
map
(
function
(
tag
)
{
return
tag
.
name
;
}).
sort
()).
to
.
deep
.
equal
([
'questionTag'
,
'tagA'
,
'tagC'
]);
}).
then
(
function
()
{
return
Promise
.
join
(
self
.
Post
.
find
({
where
:
{},
include
:
[
self
.
Tag
]
}),
self
.
Image
.
find
({
where
:
{},
include
:
[
self
.
Tag
]
}),
self
.
Question
.
find
({
where
:
{},
include
:
[
self
.
Tag
]
})
).
spread
(
function
(
post
,
image
,
question
)
{
expect
(
post
.
tags
.
length
).
to
.
equal
(
3
);
expect
(
image
.
tags
.
length
).
to
.
equal
(
3
);
expect
(
question
.
tags
.
length
).
to
.
equal
(
3
);
expect
(
post
.
tags
.
map
(
function
(
tag
)
{
return
tag
.
name
;
}).
sort
()).
to
.
deep
.
equal
([
'postTag'
,
'tagA'
,
'tagB'
]);
expect
(
image
.
tags
.
map
(
function
(
tag
)
{
return
tag
.
name
;
}).
sort
()).
to
.
deep
.
equal
([
'imageTag'
,
'tagB'
,
'tagC'
]);
expect
(
question
.
tags
.
map
(
function
(
tag
)
{
return
tag
.
name
;
}).
sort
()).
to
.
deep
.
equal
([
'questionTag'
,
'tagA'
,
'tagC'
]);
});
});
});
});
...
...
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