Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating error in sequelize

What kind of error is this?

Unhandled rejection SequelizeDatabaseError: ER_EMPTY_QUERY: Query was empty
    at Query.formatError (node_modules/sequelize/lib/dialects/mysql/query.js:159:14)
    at Query._callback (node_modules/sequelize/lib/dialects/mysql/query.js:35:21)
    at Query.Sequence.end (node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
    at Query.ErrorPacket (node_modules/mysql/lib/protocol/sequences/Query.js:94:8)
    at Protocol._parsePacket (node_modules/mysql/lib/protocol/Protocol.js:274:23)
    at Parser.write (node_modules/mysql/lib/protocol/Parser.js:77:12)
    at Protocol.write (node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (node_modules/mysql/lib/Connection.js:96:28)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)

I'm trying to update an entity with the following code:

db.Account.update({
                    'post_id': data.id
                }, {
                  where: { id: account.id }
                })
                .spread(account => {

                  next();
                });

but it doesn't work. Any idea?

like image 544
Mazzy Avatar asked Jul 16 '15 20:07

Mazzy


1 Answers

The same issue I was facing and after a lot of debugging found out the silly mistake. The reason for me was in mysql added a column and forgot to add the same to sequelize model representing the same table so for your case also will suggest you to just double check for post_id is present in Account sequelize model.

like image 84
vinit payal Avatar answered Sep 28 '22 00:09

vinit payal