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 5b0d6497
authored
Aug 02, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed didChange to hasChanged
1 parent
03137ae8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
lib/dao.js
lib/utils.js
lib/dao.js
View file @
5b0d649
...
@@ -87,7 +87,7 @@ module.exports = (function() {
...
@@ -87,7 +87,7 @@ module.exports = (function() {
DAO
.
prototype
.
get
=
DAO
.
prototype
.
getDataValue
DAO
.
prototype
.
get
=
DAO
.
prototype
.
getDataValue
DAO
.
prototype
.
setDataValue
=
function
(
name
,
value
)
{
DAO
.
prototype
.
setDataValue
=
function
(
name
,
value
)
{
if
(
Utils
.
didChange
(
this
.
dataValues
[
name
],
value
))
{
if
(
Utils
.
hasChanged
(
this
.
dataValues
[
name
],
value
))
{
this
.
isDirty
=
true
this
.
isDirty
=
true
}
}
this
.
dataValues
[
name
]
=
value
this
.
dataValues
[
name
]
=
value
...
@@ -240,7 +240,7 @@ module.exports = (function() {
...
@@ -240,7 +240,7 @@ module.exports = (function() {
(
self
.
attributes
.
indexOf
(
attr
)
>
-
1
)
(
self
.
attributes
.
indexOf
(
attr
)
>
-
1
)
)
)
if
(
updateAllowed
)
{
if
(
updateAllowed
)
{
if
(
Utils
.
didChange
(
self
[
attr
],
value
))
{
if
(
Utils
.
hasChanged
(
self
[
attr
],
value
))
{
isDirty
=
true
isDirty
=
true
}
}
self
[
attr
]
=
value
self
[
attr
]
=
value
...
@@ -346,7 +346,7 @@ module.exports = (function() {
...
@@ -346,7 +346,7 @@ module.exports = (function() {
if
(
has
!==
true
)
{
if
(
has
!==
true
)
{
this
.
__defineGetter__
(
attribute
,
has
.
get
||
function
()
{
return
this
.
dataValues
[
attribute
];
});
this
.
__defineGetter__
(
attribute
,
has
.
get
||
function
()
{
return
this
.
dataValues
[
attribute
];
});
this
.
__defineSetter__
(
attribute
,
has
.
set
||
function
(
v
)
{
this
.
__defineSetter__
(
attribute
,
has
.
set
||
function
(
v
)
{
if
(
Utils
.
didChange
(
this
.
dataValues
[
attribute
],
v
))
{
if
(
Utils
.
hasChanged
(
this
.
dataValues
[
attribute
],
v
))
{
//Only dirty the object if the change is not due to id, touchedAt, createdAt or updatedAt being initiated
//Only dirty the object if the change is not due to id, touchedAt, createdAt or updatedAt being initiated
var
updatedAtAttr
=
this
.
__options
.
underscored
?
'updated_at'
:
'updatedAt'
var
updatedAtAttr
=
this
.
__options
.
underscored
?
'updated_at'
:
'updatedAt'
,
createdAtAttr
=
this
.
__options
.
underscored
?
'created_at'
:
'createdAt'
,
createdAtAttr
=
this
.
__options
.
underscored
?
'created_at'
:
'createdAt'
...
...
lib/utils.js
View file @
5b0d649
...
@@ -252,18 +252,21 @@ var Utils = module.exports = {
...
@@ -252,18 +252,21 @@ var Utils = module.exports = {
isHash
:
function
(
obj
)
{
isHash
:
function
(
obj
)
{
return
Utils
.
_
.
isObject
(
obj
)
&&
!
Array
.
isArray
(
obj
);
return
Utils
.
_
.
isObject
(
obj
)
&&
!
Array
.
isArray
(
obj
);
},
},
didChange
:
function
(
attrValue
,
value
)
{
hasChanged
:
function
(
attrValue
,
value
)
{
//If attribute value is Date, check value as a date
//If attribute value is Date, check value as a date
if
(
Utils
.
_
.
isDate
(
attrValue
)
&&
!
Utils
.
_
.
isDate
(
value
))
{
if
(
Utils
.
_
.
isDate
(
attrValue
)
&&
!
Utils
.
_
.
isDate
(
value
))
{
value
=
new
Date
(
value
)
value
=
new
Date
(
value
)
}
}
if
(
Utils
.
_
.
isDate
(
attrValue
))
{
if
(
Utils
.
_
.
isDate
(
attrValue
))
{
return
attrValue
.
valueOf
()
!==
value
.
valueOf
()
return
attrValue
.
valueOf
()
!==
value
.
valueOf
()
}
}
//If both of them are empty, don't set as changed
//If both of them are empty, don't set as changed
if
((
attrValue
===
undefined
||
attrValue
===
null
||
attrValue
===
''
)
&&
(
value
===
undefined
||
value
===
null
||
value
===
''
))
{
if
((
attrValue
===
undefined
||
attrValue
===
null
||
attrValue
===
''
)
&&
(
value
===
undefined
||
value
===
null
||
value
===
''
))
{
return
false
return
false
}
}
return
attrValue
!==
value
return
attrValue
!==
value
},
},
argsArePrimaryKeys
:
function
(
args
,
primaryKeys
)
{
argsArePrimaryKeys
:
function
(
args
,
primaryKeys
)
{
...
...
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