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 57ecd46c
authored
Sep 19, 2014
by
overlookmotel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate expanding include all into own function
1 parent
ecf511ae
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
lib/model.js
lib/model.js
View file @
57ecd46
...
@@ -698,6 +698,7 @@ module.exports = (function() {
...
@@ -698,6 +698,7 @@ module.exports = (function() {
if
(
options
.
include
)
{
if
(
options
.
include
)
{
hasJoin
=
true
;
hasJoin
=
true
;
expandIncludeAll
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
,
tableNames
);
validateIncludedElements
.
call
(
this
,
options
,
tableNames
);
if
(
options
.
attributes
)
{
if
(
options
.
attributes
)
{
...
@@ -824,6 +825,7 @@ module.exports = (function() {
...
@@ -824,6 +825,7 @@ module.exports = (function() {
var
col
=
'*'
;
var
col
=
'*'
;
if
(
options
.
include
)
{
if
(
options
.
include
)
{
col
=
this
.
name
+
'.'
+
this
.
primaryKeyAttribute
;
col
=
this
.
name
+
'.'
+
this
.
primaryKeyAttribute
;
expandIncludeAll
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
);
}
}
...
@@ -940,6 +942,7 @@ module.exports = (function() {
...
@@ -940,6 +942,7 @@ module.exports = (function() {
if
(
!
options
.
includeValidated
)
{
if
(
!
options
.
includeValidated
)
{
conformOptions
(
options
);
conformOptions
(
options
);
if
(
options
.
include
)
{
if
(
options
.
include
)
{
expandIncludeAll
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
);
}
}
}
}
...
@@ -954,6 +957,7 @@ module.exports = (function() {
...
@@ -954,6 +957,7 @@ module.exports = (function() {
if
(
!
options
.
includeValidated
)
{
if
(
!
options
.
includeValidated
)
{
conformOptions
(
options
);
conformOptions
(
options
);
if
(
options
.
include
)
{
if
(
options
.
include
)
{
expandIncludeAll
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
);
validateIncludedElements
.
call
(
this
,
options
);
}
}
}
}
...
@@ -1756,17 +1760,7 @@ module.exports = (function() {
...
@@ -1756,17 +1760,7 @@ module.exports = (function() {
// validate all included elements
// validate all included elements
var
includes
=
options
.
include
;
var
includes
=
options
.
include
;
for
(
var
index
=
0
;
index
<
includes
.
length
;
index
++
)
{
for
(
var
index
=
0
;
index
<
includes
.
length
;
index
++
)
{
var
include
=
includes
[
index
];
var
include
=
includes
[
index
]
=
validateIncludedElement
.
call
(
this
,
includes
[
index
],
tableNames
);
if
(
include
.
all
)
{
includes
.
splice
(
index
,
1
);
index
--
;
validateIncludedAllElement
.
call
(
this
,
includes
,
include
);
continue
;
}
include
=
includes
[
index
]
=
validateIncludedElement
.
call
(
this
,
include
,
tableNames
);
include
.
parent
=
options
;
include
.
parent
=
options
;
// associations that are required or have a required child as is not a ?:M association are candidates for the subquery
// associations that are required or have a required child as is not a ?:M association are candidates for the subquery
...
@@ -1867,7 +1861,29 @@ module.exports = (function() {
...
@@ -1867,7 +1861,29 @@ module.exports = (function() {
}
}
};
};
var
validateIncludedAllElement
=
function
(
includes
,
include
)
{
var
expandIncludeAll
=
function
(
options
)
{
var
includes
=
options
.
include
;
if
(
!
includes
)
{
return
;
}
for
(
var
index
=
0
;
index
<
includes
.
length
;
index
++
)
{
var
include
=
includes
[
index
];
if
(
include
.
all
)
{
includes
.
splice
(
index
,
1
);
index
--
;
expandIncludeAllElement
.
call
(
this
,
includes
,
include
);
}
}
Utils
.
_
.
forEach
(
includes
,
function
(
include
)
{
expandIncludeAll
.
call
(
include
.
model
,
include
);
});
};
var
expandIncludeAllElement
=
function
(
includes
,
include
)
{
// check 'all' attribute provided is valid
// check 'all' attribute provided is valid
var
all
=
include
.
all
;
var
all
=
include
.
all
;
delete
include
.
all
;
delete
include
.
all
;
...
...
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