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 f0862463
authored
Jan 19, 2016
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5238 from ajfranzoia/support-bulk-silent
Support silent: true in bulk update
2 parents
a9d473d9
ec456f59
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletions
changelog.md
lib/model.js
test/integration/instance.test.js
changelog.md
View file @
f086246
# FUTURE
-
[
ADDED
]
Support silent: true in bulk update
[
#5200
](
https://github.com/sequelize/sequelize/issues/5200
)
# 3.17.3
-
[
FIXED
]
Regression with array values from security fix in 3.17.2
...
...
lib/model.js
View file @
f086246
...
...
@@ -2409,6 +2409,7 @@ Model.prototype.restore = function(options) {
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {Boolean} [options.benchmark=false] Print query execution time in milliseconds when logging SQL.
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {Boolean} [options.silent=false] If true, the updatedAt timestamp will not be updated.
*
* @return {Promise<Array<affectedCount,affectedRows>>}
*/
...
...
@@ -2450,7 +2451,7 @@ Model.prototype.update = function(values, options) {
}
}
if
(
this
.
_timestampAttributes
.
updatedAt
)
{
if
(
this
.
_timestampAttributes
.
updatedAt
&&
!
options
.
silent
)
{
values
[
this
.
_timestampAttributes
.
updatedAt
]
=
this
.
$getDefaultTimestamp
(
this
.
_timestampAttributes
.
updatedAt
)
||
Utils
.
now
(
this
.
sequelize
.
options
.
dialect
);
}
...
...
test/integration/instance.test.js
View file @
f086246
...
...
@@ -1085,6 +1085,37 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
it
(
'does not update timestamps when passing silent=true in a bulk update'
,
function
()
{
var
self
=
this
,
updatedAtPeter
,
updatedAtPaul
,
data
=
[
{
username
:
'Paul'
},
{
username
:
'Peter'
}
];
return
this
.
User
.
bulkCreate
(
data
).
then
(
function
()
{
return
self
.
User
.
findAll
();
}).
then
(
function
(
users
)
{
updatedAtPaul
=
users
[
0
].
updatedAt
;
updatedAtPeter
=
users
[
1
].
updatedAt
;
})
.
then
(
function
()
{
return
self
.
sequelize
.
Promise
.
delay
(
150
);
})
.
then
(
function
()
{
return
self
.
User
.
update
(
{
aNumber
:
1
},
{
where
:
{},
silent
:
true
}
);
}).
then
(
function
()
{
return
self
.
User
.
findAll
();
}).
then
(
function
(
users
)
{
expect
(
users
[
0
].
updatedAt
).
to
.
equalTime
(
updatedAtPeter
);
expect
(
users
[
1
].
updatedAt
).
to
.
equalTime
(
updatedAtPaul
);
});
});
describe
(
'when nothing changed'
,
function
()
{
beforeEach
(
function
()
{
...
...
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