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 30bd3b08
authored
Jan 06, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only use subQueryAttributes if subQuery is indicated (required + multi)
1 parent
9a2b4e61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
21 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/abstract/query-generator.js
View file @
30bd3b0
...
@@ -469,7 +469,7 @@ module.exports = (function() {
...
@@ -469,7 +469,7 @@ module.exports = (function() {
,
mainAttributes
=
options
.
attributes
,
mainAttributes
=
options
.
attributes
,
mainJoinQueries
=
[]
,
mainJoinQueries
=
[]
// We'll use a subquery if there's a limit, if we have hasMany associations and if any of them are filtered
// We'll use a subquery if there's a limit, if we have hasMany associations and if any of them are filtered
,
subQuery
=
limit
&&
options
&&
options
.
hasIncludeWhere
&&
options
.
hasMultiAssociation
,
subQuery
=
limit
&&
options
&&
options
.
hasIncludeWhere
&&
options
.
has
IncludeRequired
&&
options
.
has
MultiAssociation
,
subQueryItems
=
[]
,
subQueryItems
=
[]
,
subQueryAttributes
=
null
,
subQueryAttributes
=
null
,
subJoinQueries
=
[]
,
subJoinQueries
=
[]
...
@@ -538,7 +538,7 @@ module.exports = (function() {
...
@@ -538,7 +538,7 @@ module.exports = (function() {
return
self
.
quoteIdentifier
(
as
)
+
"."
+
self
.
quoteIdentifier
(
attr
)
+
" AS "
+
self
.
quoteIdentifier
(
as
+
"."
+
attr
)
return
self
.
quoteIdentifier
(
as
)
+
"."
+
self
.
quoteIdentifier
(
attr
)
+
" AS "
+
self
.
quoteIdentifier
(
as
+
"."
+
attr
)
})
})
if
(
limit
&&
include
.
hasIncludeRequired
||
include
.
required
)
{
if
(
subQuery
&&
include
.
hasIncludeRequired
||
include
.
required
)
{
subQueryAttributes
=
subQueryAttributes
.
concat
(
attributes
)
subQueryAttributes
=
subQueryAttributes
.
concat
(
attributes
)
}
else
{
}
else
{
mainAttributes
=
mainAttributes
.
concat
(
attributes
)
mainAttributes
=
mainAttributes
.
concat
(
attributes
)
...
@@ -553,7 +553,7 @@ module.exports = (function() {
...
@@ -553,7 +553,7 @@ module.exports = (function() {
})
})
if
(
options
.
includeIgnoreAttributes
!==
false
)
{
if
(
options
.
includeIgnoreAttributes
!==
false
)
{
if
(
limit
&&
include
.
hasIncludeRequired
||
include
.
required
)
{
if
(
subQuery
&&
include
.
hasIncludeRequired
||
include
.
required
)
{
subQueryAttributes
=
subQueryAttributes
.
concat
(
attributes
)
subQueryAttributes
=
subQueryAttributes
.
concat
(
attributes
)
}
else
{
}
else
{
mainAttributes
=
mainAttributes
.
concat
(
throughAttributes
)
mainAttributes
=
mainAttributes
.
concat
(
throughAttributes
)
...
@@ -617,17 +617,7 @@ module.exports = (function() {
...
@@ -617,17 +617,7 @@ module.exports = (function() {
}
}
}.
bind
(
this
))
}.
bind
(
this
))
}
}
//var conditionalJoins = ((options.hasMultiAssociation && (options.limit || options.offset)) || !options.include) && this.getConditionalJoins(options, factory),
/*if (conditionalJoins) {
query = "SELECT " + options.attributes + " FROM ( "
+ "SELECT " + options.table + ".* FROM " + options.table + this.getConditionalJoins(options, factory)
} else {*/
//query += "SELECT " + mainAttributes.join(',') + " FROM " + options.table
//query += mainJoinQueries.concat(subJoinQueries).join('')
//}
if
(
subQuery
)
{
if
(
subQuery
)
{
subQueryItems
.
push
(
"SELECT "
+
subQueryAttributes
.
join
(
','
)
+
" FROM "
+
options
.
table
)
subQueryItems
.
push
(
"SELECT "
+
subQueryAttributes
.
join
(
','
)
+
" FROM "
+
options
.
table
)
subQueryItems
.
push
(
subJoinQueries
.
join
(
''
))
subQueryItems
.
push
(
subJoinQueries
.
join
(
''
))
...
@@ -674,15 +664,8 @@ module.exports = (function() {
...
@@ -674,15 +664,8 @@ module.exports = (function() {
mainQueryItems
.
push
(
limitOrder
)
mainQueryItems
.
push
(
limitOrder
)
}
}
}
}
//console.log(subQueryItems)
/*if (conditionalJoins) {
query += ") AS " + options.table
query += joinQuery
}*/
if
(
subQuery
)
{
if
(
subQuery
)
{
//console.log(mainQueryItems)
//" + mainAttributes.join(',') + "
query
=
"SELECT "
+
mainAttributes
.
join
(
','
)
+
" FROM ("
query
=
"SELECT "
+
mainAttributes
.
join
(
','
)
+
" FROM ("
query
+=
subQueryItems
.
join
(
''
)
query
+=
subQueryItems
.
join
(
''
)
query
+=
") AS "
+
options
.
table
query
+=
") AS "
+
options
.
table
...
...
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