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.

queryInterface.bulkUpdate fails with MySQL

See original GitHub issue

What are you doing?

Update a row in a table using only the QueryInterface, since I’m not able to not to use the Models directly.

await sequelizeInstance.getQueryInterface().bulkUpdate('Table', { data: 'foo' }, { key: 'bar' }, { transaction });

What do you expect to happen?

The row should be updated.

What is actually happening?

An Exception is thrown:

TypeError: valueSets.map is not a function
    at Function.bulkBuild (node_modules/sequelize/lib/model.js:1986:22)
    at Function._target.(anonymous function) [as bulkBuild] (node_modules/sequelize-typescript/lib/models/BaseModel.js:36:41)
    at Query.handleSelectQuery (node_modules/sequelize/lib/dialects/abstract/query.js:303:27)
    at Query.formatResults (node_modules/sequelize/lib/dialects/mysql/query.js:135:21)
    at Utils.Promise.then.then.results (node_modules/sequelize/lib/dialects/mysql/query.js:88:29)
    at tryCatcher (node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

The problem seems to be, that the sequelizeInstance.getQueryInterface().bulkUpdate() function does not set the options.type to connection.QueryTypes.BULKUPDATE or connection.QueryTypes.UPDATE. So the result parser thinks it’s a SELECT query.

Dialect: mysql Sequelize version: 4.43 Tested with latest release: No (If yes, specify that version)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
krazi3commented, Oct 6, 2019

@papb I have added a fix for this issue. This is my first PR submitted to sequelize and i would like to continue contributing more in the future. 😄

0reactions
papbcommented, Oct 7, 2019

Fixed by #11515

Read more comments on GitHub >

github_iconTop Results From Across the Web

bulkUpdate in sequelize orm - node.js - Stack Overflow
Use the bulkCreate to bulkUpdate method. ... that there is a bulkUpdate for QueryInterface , but there isn't one for Model . ......
Read more >
QueryInterface - Sequelize
An easy-to-use multi SQL dialect ORM for Node.js.
Read more >
How To Use Queryinterface.Bulkupdate From Sequelize ...
bulkUpdate method? I'm trying to update several columns using a seeder file.But I cannot get it work log keeps trowing.Seed file failed with....
Read more >
How to use queryInterface.bulkUpdate from Sequelize when it ...
I want to use Sequelize migration to update a table in my Postgres database. My SQL query uses de ? operator from Postgres...
Read more >
Upgrade to v5 - Manual | Sequelize
To avoid problems when upgrading, please check all your custom validators defined per attribute, ... docs(query-interface): add bulkUpdate docs #10005 ...
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