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 a08d1ca4
authored
Jan 07, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed several issues and added in a spec for saving records with no primary keys.
1 parent
7287f332
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
lib/dao-factory.js
spec/dao.spec.js
lib/dao-factory.js
View file @
a08d1ca
...
...
@@ -151,11 +151,11 @@ module.exports = (function() {
if
(
!
options
.
include
[
daoName
])
{
options
.
include
[
daoName
]
=
this
.
getAssociationByAlias
(
daoName
).
target
}
}.
bind
(
this
))
}
}.
bind
(
this
));
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
optcpy
.
where
||
undefined
;
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
options
.
where
||
undefined
;
}
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
}
...
...
@@ -217,14 +217,14 @@ module.exports = (function() {
if
(
!
options
.
include
[
daoName
])
{
options
.
include
[
daoName
]
=
this
.
getAssociationByAlias
(
daoName
).
target
}
}.
bind
(
this
))
}.
bind
(
this
));
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
options
.
where
||
undefined
;
}
options
.
limit
=
1
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
optcpy
.
where
||
undefined
;
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
,
type
:
'SELECT'
,
hasJoin
:
hasJoin
})
}
...
...
spec/dao.spec.js
View file @
a08d1ca
...
...
@@ -19,9 +19,17 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
touchedAt
:
{
type
:
DataTypes
.
DATE
,
defaultValue
:
DataTypes
.
NOW
},
aNumber
:
{
type
:
DataTypes
.
INTEGER
}
})
self
.
HistoryLog
=
sequelize
.
define
(
'HistoryLog'
,
{
someText
:
{
type
:
DataTypes
.
STRING
},
aNumber
:
{
type
:
DataTypes
.
INTEGER
},
aRandomId
:
{
type
:
DataTypes
.
INTEGER
}
})
},
onComplete
:
function
()
{
self
.
User
.
sync
({
force
:
true
}).
success
(
done
)
self
.
User
.
sync
({
force
:
true
}).
success
(
function
(){
self
.
HistoryLog
.
sync
({
force
:
true
}).
success
(
done
)
})
}
})
})
...
...
@@ -67,6 +75,15 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
done
()
})
})
it
(
'saves a record with no primary key'
,
function
(
done
){
this
.
HistoryLog
.
create
({
someText
:
'Some random text'
,
aNumber
:
3
,
aRandomId
:
5
}).
success
(
function
(
log
)
{
log
.
updateAttributes
({
aNumber
:
5
}).
success
(
function
(
newLog
){
expect
(
newLog
.
aNumber
).
toEqual
(
5
)
done
()
})
})
})
})
describe
(
'toJSON'
,
function
toJSON
()
{
...
...
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