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 7139a630
authored
Mar 27, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extracted log in order to be able to use it somewhere else
1 parent
27b88487
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
lib/dialects/abstract/query.js
lib/dialects/abstract/query.js
View file @
7139a63
...
@@ -259,20 +259,7 @@ module.exports = (function() {
...
@@ -259,20 +259,7 @@ module.exports = (function() {
result
=
result
.
map
(
Dot
.
transform
)
result
=
result
.
map
(
Dot
.
transform
)
}
else
if
(
this
.
options
.
hasJoin
===
true
)
{
}
else
if
(
this
.
options
.
hasJoin
===
true
)
{
result
=
prepareJoinData
.
call
(
this
,
results
)
result
=
transformRowsWithEagerLoadingIntoDaos
.
call
(
this
,
results
)
result
=
groupDataByCalleeFactory
.
call
(
this
,
result
).
map
(
function
(
result
)
{
// let's build the actual dao instance first...
var
dao
=
this
.
callee
.
build
(
result
[
this
.
callee
.
tableName
],
{
isNewRecord
:
false
})
// ... and afterwards the prefetched associations
for
(
var
tableName
in
result
)
{
if
(
result
.
hasOwnProperty
(
tableName
)
&&
(
tableName
!==
this
.
callee
.
tableName
))
{
buildAssociatedDaoInstances
.
call
(
this
,
tableName
,
result
[
tableName
],
dao
)
}
}
return
dao
}.
bind
(
this
))
}
else
{
}
else
{
result
=
results
.
map
(
function
(
result
)
{
result
=
results
.
map
(
function
(
result
)
{
return
this
.
callee
.
build
(
result
,
{
isNewRecord
:
false
})
return
this
.
callee
.
build
(
result
,
{
isNewRecord
:
false
})
...
@@ -287,6 +274,31 @@ module.exports = (function() {
...
@@ -287,6 +274,31 @@ module.exports = (function() {
return
result
return
result
}
}
var
transformRowsWithEagerLoadingIntoDaos
=
function
(
results
)
{
var
result
=
[]
result
=
prepareJoinData
.
call
(
this
,
results
)
result
=
groupDataByCalleeFactory
.
call
(
this
,
result
).
map
(
function
(
result
)
{
return
transformRowWithEagerLoadingIntoDao
.
call
(
this
,
result
)
}.
bind
(
this
))
return
result
}
var
transformRowWithEagerLoadingIntoDao
=
function
(
result
,
dao
)
{
// let's build the actual dao instance first...
dao
=
dao
||
this
.
callee
.
build
(
result
[
this
.
callee
.
tableName
],
{
isNewRecord
:
false
})
// ... and afterwards the prefetched associations
for
(
var
tableName
in
result
)
{
if
(
result
.
hasOwnProperty
(
tableName
)
&&
(
tableName
!==
this
.
callee
.
tableName
))
{
buildAssociatedDaoInstances
.
call
(
this
,
tableName
,
result
[
tableName
],
dao
)
}
}
return
dao
}
var
buildAssociatedDaoInstances
=
function
(
tableName
,
associationData
,
dao
)
{
var
buildAssociatedDaoInstances
=
function
(
tableName
,
associationData
,
dao
)
{
var
associatedDaoFactory
=
this
.
sequelize
.
daoFactoryManager
.
getDAO
(
tableName
,
{
attribute
:
'tableName'
})
var
associatedDaoFactory
=
this
.
sequelize
.
daoFactoryManager
.
getDAO
(
tableName
,
{
attribute
:
'tableName'
})
,
association
=
null
,
association
=
null
...
@@ -311,7 +323,7 @@ module.exports = (function() {
...
@@ -311,7 +323,7 @@ module.exports = (function() {
associationData
.
forEach
(
function
(
data
)
{
associationData
.
forEach
(
function
(
data
)
{
var
daoInstance
=
associatedDaoFactory
.
build
(
data
,
{
isNewRecord
:
false
})
var
daoInstance
=
associatedDaoFactory
.
build
(
data
,
{
isNewRecord
:
false
})
,
isEmpty
=
!
Utils
.
firstValueOfHash
(
daoInstance
.
identifiers
)
,
isEmpty
=
!
Utils
.
firstValueOfHash
(
daoInstance
.
identifiers
)
if
([
'BelongsTo'
,
'HasOne'
].
indexOf
(
association
.
associationType
)
>
-
1
)
{
if
([
'BelongsTo'
,
'HasOne'
].
indexOf
(
association
.
associationType
)
>
-
1
)
{
accessor
=
Utils
.
singularize
(
accessor
)
accessor
=
Utils
.
singularize
(
accessor
)
...
@@ -326,7 +338,8 @@ module.exports = (function() {
...
@@ -326,7 +338,8 @@ module.exports = (function() {
// add the accessor to the eagerly loaded associations array
// add the accessor to the eagerly loaded associations array
dao
.
__eagerlyLoadedAssociations
=
Utils
.
_
.
uniq
(
dao
.
__eagerlyLoadedAssociations
.
concat
([
accessor
]))
dao
.
__eagerlyLoadedAssociations
=
Utils
.
_
.
uniq
(
dao
.
__eagerlyLoadedAssociations
.
concat
([
accessor
]))
})
dao
.
__eagerlyLoadedOptions
=
(
this
.
options
&&
this
.
options
.
include
)
?
this
.
options
.
include
:
[]
}.
bind
(
this
))
}
}
var
isShowOrDescribeQuery
=
function
()
{
var
isShowOrDescribeQuery
=
function
()
{
...
...
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