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 f23cdeb0
authored
Apr 29, 2014
by
José Moreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug (cause by required on N:M)
1 parent
5ef9edc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/abstract/query-generator.js
View file @
f23cdeb
...
@@ -737,25 +737,26 @@ module.exports = (function() {
...
@@ -737,25 +737,26 @@ module.exports = (function() {
joinQueryItem
+=
sourceJoinOn
joinQueryItem
+=
sourceJoinOn
// Generate join SQL for right side of through
// Generate join SQL for right side of through
joinQueryItem
+=
joinType
+
self
.
quoteTable
(
table
,
as
)
+
" ON "
joinQueryItem
+=
joinType
+
self
.
quoteTable
(
table
,
as
)
+
" ON "
joinQueryItem
+=
targetJoinOn
joinQueryItem
+=
targetJoinOn
if
(
include
.
where
)
{
if
(
include
.
where
)
{
targetWhere
=
self
.
getWhereConditions
(
include
.
where
,
self
.
sequelize
.
literal
(
self
.
quoteIdentifier
(
as
)),
include
.
daoFactory
,
whereOptions
)
targetWhere
=
self
.
getWhereConditions
(
include
.
where
,
self
.
sequelize
.
literal
(
self
.
quoteIdentifier
(
as
)),
include
.
daoFactory
,
whereOptions
)
joinQueryItem
+=
" AND "
+
targetWhere
joinQueryItem
+=
" AND "
+
targetWhere
if
(
subQuery
)
{
if
(
subQuery
)
{
if
(
!
options
.
where
)
options
.
where
=
{}
if
(
!
options
.
where
)
options
.
where
=
{}
// Creating the as-is where for the subQuery, checks that the required association exists
// Creating the as-is where for the subQuery, checks that the required association exists
var
_where
=
"("
;
options
.
where
[
"__"
+
throughAs
]
=
self
.
sequelize
.
asIs
([
'('
,
_where
+=
"SELECT "
+
self
.
quoteIdentifier
(
identSource
)
+
" FROM "
+
self
.
quoteTable
(
throughTable
,
throughAs
);
_where
+=
joinType
+
self
.
quoteTable
(
table
,
as
)
+
" ON "
+
targetJoinOn
;
"SELECT "
+
self
.
quoteIdentifier
(
throughAs
)
+
"."
+
self
.
quoteIdentifier
(
identSource
)
+
" FROM "
+
self
.
quoteTable
(
throughTable
,
throughAs
),
_where
+=
" WHERE "
+
sourceJoinOn
+
" AND "
+
targetWhere
+
" LIMIT 1"
!
include
.
required
&&
joinType
+
self
.
quoteTable
(
association
.
source
.
tableName
,
tableSource
)
+
" ON "
+
sourceJoinOn
||
''
,
_where
+=
")"
;
joinType
+
self
.
quoteTable
(
table
,
as
)
+
" ON "
+
targetJoinOn
,
_where
+=
" IS NOT NULL"
"WHERE "
+
(
!
include
.
required
&&
targetWhere
||
sourceJoinOn
+
" AND "
+
targetWhere
),
"LIMIT 1"
,
options
.
where
[
"__"
+
throughAs
]
=
self
.
sequelize
.
asIs
(
_where
)
')'
,
'IS NOT NULL'
].
join
(
' '
))
}
}
}
}
}
else
{
}
else
{
...
...
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