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 ef31e540
authored
Jul 30, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made sure updatedAt was being updated when we setAttributes.
1 parent
e68552f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
lib/dao.js
test/dao.test.js
lib/dao.js
View file @
ef31e54
...
@@ -223,7 +223,7 @@ module.exports = (function() {
...
@@ -223,7 +223,7 @@ module.exports = (function() {
if
(
this
.
isNewRecord
!==
true
)
{
if
(
this
.
isNewRecord
!==
true
)
{
readOnlyAttributes
.
push
(
this
.
daoFactory
.
options
.
underscored
===
true
?
'created_at'
:
'createdAt'
)
readOnlyAttributes
.
push
(
this
.
daoFactory
.
options
.
underscored
===
true
?
'created_at'
:
'createdAt'
)
}
}
readOnlyAttributes
.
push
(
this
.
daoFactory
.
options
.
underscored
===
true
?
'updated_at'
:
'updatedAt'
)
//
readOnlyAttributes.push(this.daoFactory.options.underscored === true ? 'updated_at' : 'updatedAt')
readOnlyAttributes
.
push
(
this
.
daoFactory
.
options
.
underscored
===
true
?
'deleted_at'
:
'deletedAt'
)
readOnlyAttributes
.
push
(
this
.
daoFactory
.
options
.
underscored
===
true
?
'deleted_at'
:
'deletedAt'
)
Utils
.
_
.
each
(
updates
,
function
(
value
,
attr
)
{
Utils
.
_
.
each
(
updates
,
function
(
value
,
attr
)
{
...
@@ -235,6 +235,11 @@ module.exports = (function() {
...
@@ -235,6 +235,11 @@ module.exports = (function() {
updateAllowed
&&
(
self
[
attr
]
=
value
)
updateAllowed
&&
(
self
[
attr
]
=
value
)
})
})
// since we're updating the record, we should be updating the updatedAt column..
if
(
this
.
daoFactory
.
options
.
timestamps
===
true
)
{
self
[
this
.
daoFactory
.
options
.
underscored
===
true
?
'updated_at'
:
'updatedAt'
]
=
new
Date
()
}
}
}
DAO
.
prototype
.
destroy
=
function
()
{
DAO
.
prototype
.
destroy
=
function
()
{
...
...
test/dao.test.js
View file @
ef31e54
...
@@ -985,17 +985,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
...
@@ -985,17 +985,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
identifier
:
'identifier'
identifier
:
'identifier'
}).
success
(
function
(
user
)
{
}).
success
(
function
(
user
)
{
var
oldCreatedAt
=
user
.
createdAt
var
oldCreatedAt
=
user
.
createdAt
,
oldUpdatedAt
=
user
.
updatedAt
,
oldIdentifier
=
user
.
identifier
,
oldIdentifier
=
user
.
identifier
user
.
updateAttributes
({
setTimeout
(
function
()
{
name
:
'foobar'
,
user
.
updateAttributes
({
createdAt
:
new
Date
(
2000
,
1
,
1
),
name
:
'foobar'
,
identifier
:
'another identifier'
createdAt
:
new
Date
(
2000
,
1
,
1
),
}).
success
(
function
(
user
)
{
identifier
:
'another identifier'
expect
(
new
Date
(
user
.
createdAt
)).
to
.
equalDate
(
new
Date
(
oldCreatedAt
))
}).
success
(
function
(
user
)
{
expect
(
user
.
identifier
).
to
.
equal
(
oldIdentifier
)
expect
(
new
Date
(
user
.
createdAt
)).
to
.
equalDate
(
new
Date
(
oldCreatedAt
))
done
()
expect
(
new
Date
(
user
.
updatedAt
)).
to
.
not
.
equalTime
(
new
Date
(
oldUpdatedAt
))
})
expect
(
user
.
identifier
).
to
.
equal
(
oldIdentifier
)
done
()
})
},
1000
)
})
})
})
})
})
})
...
...
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