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 33caab9f
authored
Apr 09, 2014
by
José Moreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eager Loading of non required but conditionable
Fixes #1614
1 parent
d311b2c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
lib/dialects/abstract/query-generator.js
test/associations/has-many.test.js
lib/dialects/abstract/query-generator.js
View file @
33caab9
...
...
@@ -779,7 +779,7 @@ module.exports = (function() {
joinQueryItem
+=
" AND "
+
self
.
getWhereConditions
(
include
.
where
,
self
.
sequelize
.
literal
(
self
.
quoteIdentifier
(
as
)),
include
.
daoFactory
,
whereOptions
)
// If its a multi association we need to add a where query to the main where (executed in the subquery)
if
(
subQuery
&&
association
.
isMultiAssociation
)
{
if
(
subQuery
&&
association
.
isMultiAssociation
&&
include
.
required
)
{
if
(
!
options
.
where
)
options
.
where
=
{}
// Creating the as-is where for the subQuery, checks that the required association exists
...
...
test/associations/has-many.test.js
View file @
33caab9
...
...
@@ -701,16 +701,16 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
it
(
"get associated objects with an eager load with conditions but not required"
,
function
(
done
)
{
var
Label
=
this
.
sequelize
.
define
(
'Label'
,
{
'title'
:
DataTypes
.
STRING
,
'isActive'
:
DataTypes
.
BOOLEAN
})
,
Task
=
this
.
Task
,
User
=
this
.
User
Task
.
hasMany
(
Label
)
Label
.
hasMany
(
Task
)
Label
.
sync
({
force
:
true
}).
success
(
function
()
{
this
.
User
.
find
({
User
.
find
({
where
:
{
username
:
'John'
},
include
:
[
{
model
:
this
.
Task
,
required
:
false
,
include
:
[
{
model
:
this
.
Label
,
required
:
false
,
where
:
{
a
ctive
:
1
}
}
{
model
:
Task
,
required
:
false
,
include
:
[
{
model
:
Label
,
required
:
false
,
where
:
{
isA
ctive
:
1
}
}
]}
]
}).
done
(
function
(
err
,
john
)
{
...
...
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