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 42bb3458
authored
Mar 23, 2014
by
Tiago Ribeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug when only createdAt is enabled
1 parent
70a0cb3e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
lib/dao.js
test/dao.test.js
lib/dao.js
View file @
42bb345
...
@@ -358,7 +358,7 @@ module.exports = (function() {
...
@@ -358,7 +358,7 @@ module.exports = (function() {
&&
!!
self
.
Model
.
rawAttributes
[
createdAtAttr
].
defaultValue
&&
!!
self
.
Model
.
rawAttributes
[
createdAtAttr
].
defaultValue
)
)
?
self
.
Model
.
rawAttributes
[
createdAtAttr
].
defaultValue
?
self
.
Model
.
rawAttributes
[
createdAtAttr
].
defaultValue
:
values
[
updatedAtAttr
]
)
:
Utils
.
now
(
self
.
sequelize
.
options
.
dialect
)
)
}
}
var
query
=
null
var
query
=
null
...
...
test/dao.test.js
View file @
42bb345
...
@@ -863,6 +863,38 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
...
@@ -863,6 +863,38 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
})
})
describe
(
'with custom timestamp options'
,
function
()
{
var
now
=
Date
.
now
()
it
(
"updates the createdAt column if updatedAt is disabled"
,
function
(
done
)
{
var
User2
=
this
.
sequelize
.
define
(
'User2'
,
{
username
:
DataTypes
.
STRING
},
{
updatedAt
:
false
})
User2
.
sync
().
success
(
function
()
{
User2
.
create
({
username
:
'john doe'
}).
success
(
function
(
johnDoe
)
{
expect
(
johnDoe
.
updatedAt
).
to
.
be
.
undefined
;
expect
(
now
).
to
.
be
.
below
(
johnDoe
.
createdAt
.
getTime
())
done
()
})
})
})
it
(
"updates the updatedAt column if createdAt is disabled"
,
function
(
done
)
{
var
User2
=
this
.
sequelize
.
define
(
'User2'
,
{
username
:
DataTypes
.
STRING
},
{
createdAt
:
false
})
User2
.
sync
().
success
(
function
()
{
User2
.
create
({
username
:
'john doe'
}).
success
(
function
(
johnDoe
)
{
expect
(
johnDoe
.
createdAt
).
to
.
be
.
undefined
;
expect
(
now
).
to
.
be
.
below
(
johnDoe
.
updatedAt
.
getTime
())
done
()
})
})
})
})
it
(
'should fail a validation upon creating'
,
function
(
done
){
it
(
'should fail a validation upon creating'
,
function
(
done
){
this
.
User
.
create
({
aNumber
:
0
,
validateTest
:
'hello'
}).
error
(
function
(
err
){
this
.
User
.
create
({
aNumber
:
0
,
validateTest
:
'hello'
}).
error
(
function
(
err
){
expect
(
err
).
to
.
exist
expect
(
err
).
to
.
exist
...
...
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