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 2e096c06
authored
Aug 20, 2014
by
ThePoloQ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update query-generator.js
1 parent
0dff27a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/abstract/query-generator.js
View file @
2e096c0
...
...
@@ -527,6 +527,7 @@ module.exports = (function() {
// We'll use a subquery if we have hasMany associations and a limit and a filtered/required association
,
subQuery
=
limit
&&
(
options
.
hasIncludeWhere
||
options
.
hasIncludeRequired
||
options
.
hasMultiAssociation
)
,
subQueryItems
=
[]
,
subQueryAs
=
[]
,
subQueryAttributes
=
null
,
subJoinQueries
=
[]
...
...
@@ -583,6 +584,7 @@ module.exports = (function() {
if
(
subQuery
)
{
// We need primary keys
subQueryAttributes
=
mainAttributes
subQueryAs
.
push
(
options
.
table
.
replace
(
/
\`
/g
,
''
))
mainAttributes
=
[
options
.
table
+
'.*'
]
}
...
...
@@ -607,6 +609,10 @@ module.exports = (function() {
if
(
tableName
!==
parentTable
)
{
as
=
parentTable
+
'.'
+
include
.
as
}
if
(
include
.
subQuery
&&
subQuery
){
subQueryAs
.
push
(
as
);
}
// includeIgnoreAttributes is used by aggregate functions
if
(
options
.
includeIgnoreAttributes
!==
false
)
{
...
...
@@ -795,10 +801,20 @@ module.exports = (function() {
if
(
Array
.
isArray
(
options
.
order
))
{
options
.
order
.
forEach
(
function
(
t
)
{
var
strOrder
=
this
.
quote
(
t
,
factory
)
var
asName
=
strOrder
.
match
(
/`
(
.*
)
`
\.
/
)
if
(
subQuery
&&
!
(
t
[
0
]
instanceof
daoFactory
)
&&
!
(
t
[
0
].
model
instanceof
daoFactory
))
{
subQueryOrder
.
push
(
this
.
quote
(
t
,
factory
))
if
(
asName
&&
subQueryAs
.
indexOf
(
asName
[
1
])
>
-
1
){
subQueryOrder
.
push
(
strOrder
)
}
}
if
(
subQuery
&&
asName
&&
asName
[
1
]
!=
subQueryAs
[
0
]
&&
subQueryAs
.
indexOf
(
asName
[
1
])
>
-
1
){
mainQueryOrder
.
push
(
strOrder
.
replace
(
/`
\.
`/
,
'.'
))
}
else
{
mainQueryOrder
.
push
(
strOrder
)
}
mainQueryOrder
.
push
(
this
.
quote
(
t
,
factory
))
}.
bind
(
this
))
}
else
{
mainQueryOrder
.
push
(
options
.
order
)
...
...
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