queryInterface.bulkUpdate fails with MySQL
See original GitHub issueWhat 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:
- Created 4 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top 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 >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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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. 😄
Fixed by #11515