question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating only updatedAt on a model does not cause an update, even with silent: true

See original GitHub issue

What are you doing?

person = Person.create({ name: 'Original Name'})
await Person.update({ updatedAt: new Date('02-26-1991')}, {where: { id: person.id }, silent: true})
// [ 0 ]

await person.reload()
await person.updatedAt
// 2019-04-12T20:13:52.923Z

await Person.update({ updatedAt: new Date('02-26-1991'), name: 'A New Name'}, {where: { id: person.id }, silent: true})
Executing (default): UPDATE "Person" SET "updatedAt"=$1,"name"=$2 WHERE "id" = $3
// [ 1 ]

await person.reload()
person.updatedAt
// 1991-02-26T05:00:00.000Z

To Reproduce Steps to reproduce the behavior:

  1. Create a model Person and an instance person
  2. Use Person.update to update only the updatedAt field on person
  3. Reload person to see that updatedAt has not been updated

What do you expect to happen?

I expected updatedAt to be updated,

What is actually happening?

updatedAt was not updated

Environment

Dialect:

  • mysql
  • postgres
  • sqlite
  • mssql
  • any Dialect library version: XXX Database version: PostgreSQL 9.6 Sequelize version: 5.10.0 Node Version: 10.15.3 OS: Ubuntu 18.04.1 on Windows 10 Tested with latest release:
  • No
  • Yes, specify that version: 5.10.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jamellingcommented, Jul 11, 2019

I only use it while doing tests for some filtering of data by updatedAt times.

I think it was introduced as a side effect of https://github.com/sequelize/sequelize/pull/10248, which was to prevent updating the updatedAt time when Model.update({ }, { where: { id: someId } }) was called, as this used to behave like I expect it to.

0reactions
papbcommented, Oct 17, 2019

Duplicate of #3759

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to exclude updatedAt in sequelize when updating row
I have researched a little, with "silent:true" and some other suggestion. But I cannot make it to work. The "updatedAt" is till being...
Read more >
Use ->update() without updating timestamps - Laracasts
So I have a query that updates many hundreds of rows at a time, eg. Model::where('something', '=', $something)->update(['status' => 'Unallocated']);.
Read more >
Updatemany updates the updatedAt timestamp (using ...
Updatemany updates the updatedAt timestamp (using Mongoose) of all the records. Does it make it slow as it needs to go through all...
Read more >
sequelize timestamp false | The AI Search Engine You Control
Use the silent option for MyModel.update() . From the docs: [options.silent=false] Boolean If true, the updatedAt timestamp will not be updated ...
Read more >
lib/model.js | Sequelize
* @param {boolean} [options.silent=false] If true, the updatedAt timestamp will not be updated. * @param {boolean} [options.validate=true] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found