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 3f6100e6
authored
Jan 28, 2016
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5324 from tornillo/issue5275
Fix model update with individualHooks
2 parents
ae89e846
226cb237
Hide 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 @
3f6100e
...
...
@@ -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 @
3f6100e
...
...
@@ -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