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 780f7c00
authored
Apr 29, 2018
by
maayany_h
Committed by
Sushant
Apr 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change(model): setDataValue should not mark null to null as changed (#9347)
1 parent
21ee1c87
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
lib/model.js
test/unit/instance/changed.test.js
lib/model.js
View file @
780f7c0
...
...
@@ -3213,7 +3213,7 @@ class Model {
*/
setDataValue
(
key
,
value
)
{
const
originalValue
=
this
.
_previousDataValues
[
key
];
if
(
!
Utils
.
isPrimitive
(
value
)
||
value
!==
originalValue
)
{
if
(
(
!
Utils
.
isPrimitive
(
value
)
&&
value
!==
null
)
||
value
!==
originalValue
)
{
this
.
changed
(
key
,
true
);
}
...
...
test/unit/instance/changed.test.js
View file @
780f7c0
...
...
@@ -170,5 +170,22 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
expect
(
user
.
changed
(
attr
),
`
${
attr
}
is not changed`
).
to
.
equal
(
false
);
}
});
describe
(
'setDataValue'
,
()
=>
{
it
(
'should return falsy for unchanged primitive'
,
function
()
{
const
user
=
this
.
User
.
build
({
name
:
'a'
,
meta
:
null
},
{
isNewRecord
:
false
,
raw
:
true
});
user
.
setDataValue
(
'name'
,
'a'
);
user
.
setDataValue
(
'meta'
,
null
);
expect
(
user
.
changed
(
'name'
)).
to
.
equal
(
false
);
expect
(
user
.
changed
(
'meta'
)).
to
.
equal
(
false
);
});
});
});
});
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