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 bae5c971
authored
Feb 17, 2013
by
Ricardo Graça
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #447
1 parent
fe7703c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
lib/dao-factory.js
spec/dao.spec.js
lib/dao-factory.js
View file @
bae5c97
...
@@ -140,12 +140,13 @@ module.exports = (function() {
...
@@ -140,12 +140,13 @@ module.exports = (function() {
}
}
DAOFactory
.
prototype
.
findAll
=
function
(
options
)
{
DAOFactory
.
prototype
.
findAll
=
function
(
options
)
{
var
hasJoin
=
false
;
var
hasJoin
=
false
var
options
=
Utils
.
_
.
clone
(
options
)
if
((
typeof
options
===
'object'
)
&&
(
options
.
hasOwnProperty
(
'include'
)))
{
if
((
typeof
options
===
'object'
)
&&
(
options
.
hasOwnProperty
(
'include'
)))
{
var
includes
=
options
.
include
var
includes
=
options
.
include
hasJoin
=
true
;
hasJoin
=
true
options
.
include
=
{}
options
.
include
=
{}
includes
.
forEach
(
function
(
daoName
)
{
includes
.
forEach
(
function
(
daoName
)
{
...
@@ -154,10 +155,10 @@ module.exports = (function() {
...
@@ -154,10 +155,10 @@ module.exports = (function() {
if
(
!
options
.
include
[
daoName
])
{
if
(
!
options
.
include
[
daoName
])
{
options
.
include
[
daoName
]
=
this
.
getAssociationByAlias
(
daoName
).
target
options
.
include
[
daoName
]
=
this
.
getAssociationByAlias
(
daoName
).
target
}
}
}.
bind
(
this
))
;
}.
bind
(
this
))
// whereCollection is used for
non-primary key updates
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
options
.
where
||
null
;
this
.
options
.
whereCollection
=
options
.
where
||
null
}
}
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
...
@@ -168,7 +169,7 @@ module.exports = (function() {
...
@@ -168,7 +169,7 @@ module.exports = (function() {
var
optcpy
=
Utils
.
_
.
clone
(
options
)
var
optcpy
=
Utils
.
_
.
clone
(
options
)
optcpy
.
attributes
=
optcpy
.
attributes
||
[
Utils
.
addTicks
(
this
.
tableName
)
+
".*"
]
optcpy
.
attributes
=
optcpy
.
attributes
||
[
Utils
.
addTicks
(
this
.
tableName
)
+
".*"
]
// whereCollection is used for
non-primary key updates
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
optcpy
.
where
||
null
;
this
.
options
.
whereCollection
=
optcpy
.
where
||
null
;
return
this
.
QueryInterface
.
select
(
this
,
[
this
.
tableName
,
joinTableName
],
optcpy
,
{
type
:
'SELECT'
})
return
this
.
QueryInterface
.
select
(
this
,
[
this
.
tableName
,
joinTableName
],
optcpy
,
{
type
:
'SELECT'
})
...
...
spec/dao.spec.js
View file @
bae5c97
...
@@ -168,5 +168,20 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
...
@@ -168,5 +168,20 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
}.
bind
(
this
))
}.
bind
(
this
))
}.
bind
(
this
))
}.
bind
(
this
))
})
})
it
(
"can reuse query option objects"
,
function
(
done
)
{
this
.
User
.
create
({
username
:
'fnord'
}).
success
(
function
()
{
var
query
=
{
where
:
{
username
:
'fnord'
}}
this
.
User
.
findAll
(
query
).
success
(
function
(
users
)
{
expect
(
users
[
0
].
username
).
toEqual
(
'fnord'
)
this
.
User
.
findAll
(
query
).
success
(
function
(
users
)
{
expect
(
users
[
0
].
username
).
toEqual
(
'fnord'
)
done
()
}.
bind
(
this
))
}.
bind
(
this
))
}.
bind
(
this
))
})
})
})
})
})
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