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 226cb237
authored
Jan 28, 2016
by
tornillo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix model update with individualHooks
1 parent
ae89e846
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
lib/model.js
test/integration/model.test.js
lib/model.js
View file @
226cb23
...
...
@@ -2538,10 +2538,12 @@ Model.prototype.update = function(values, options) {
instances
=
_instances
;
if
(
!
different
)
{
var
keys
=
Object
.
keys
(
changedValues
);
// Hooks do not change values or change them uniformly
if
(
Object
.
keys
(
changedValues
)
.
length
)
{
if
(
keys
.
length
)
{
// Hooks change values - record changes in valuesUse so they are executed
valuesUse
=
changedValues
;
options
.
fields
=
Utils
.
_
.
union
(
options
.
fields
,
keys
);
}
return
;
}
else
{
...
...
test/integration/model.test.js
View file @
226cb23
...
...
@@ -1050,6 +1050,22 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
it
(
'should properly set data when individualHooks are true'
,
function
()
{
var
self
=
this
;
self
.
User
.
beforeUpdate
(
function
(
instance
)
{
instance
.
set
(
'intVal'
,
1
);
});
return
self
.
User
.
create
({
username
:
'Peter'
}).
then
(
function
(
user
)
{
return
self
.
User
.
update
({
data
:
'test'
},
{
where
:
{
id
:
user
.
id
},
individualHooks
:
true
}).
then
(
function
()
{
return
self
.
User
.
findById
(
user
.
id
).
then
(
function
(
userUpdated
){
expect
(
userUpdated
.
intVal
).
to
.
be
.
equal
(
1
);
});
});
});
});
it
(
'sets updatedAt to the current timestamp'
,
function
()
{
var
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
},
{
username
:
'Paul'
,
secretValue
:
'42'
},
...
...
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