A
A
Alex Wells2017-07-02 23:23:14
ORM
Alex Wells, 2017-07-02 23:23:14

Sequelize incomprehensible error?

Hello.
There is node7, sequelize 4.2, two models.
When executing a simple query:

models.ClassicBet.findAll({ where: {gameId: game.id}}).then(bets => initGame(game, bets));

An error like this is thrown:
{ Error: Unknown column 'UserSteamID' in 'field list'
       at Packet.asError (D:\Programming\NodeJS\ozzgame2\node_modules\mysql2\lib\packets\packet.js:701:13)
       at Query.Command.execute (D:\Programming\NodeJS\ozzgame2\node_modules\mysql2\lib\commands\command.js:28:22)
       at Connection.handlePacket (D:\Programming\NodeJS\ozzgame2\node_modules\mysql2\lib\connection.js:500:28)
       at PacketParser.onPacket (D:\Programming\NodeJS\ozzgame2\node_modules\mysql2\lib\connection.js:94:16)
       at PacketParser.executeStart (D:\Programming\NodeJS\ozzgame2\node_modules\mysql2\lib\packet_parser.js:77:14)
       at Socket.<anonymous> (D:\Programming\NodeJS\ozzgame2\node_modules\mysql2\lib\connection.js:102:29)
       at emitOne (events.js:115:13)
       at Socket.emit (events.js:210:7)
       at Socket.EventEmitter.emit (D:\Programming\NodeJS\ozzgame2\node_modules\sc-domain\index.js:12:31)
       at addChunk (_stream_readable.js:250:12)
       at readableAddChunk (_stream_readable.js:237:11)
       at Socket.Readable.push (_stream_readable.js:195:10)
       at TCP.onread (net.js:588:20)
     code: 'ER_BAD_FIELD_ERROR',
     errno: 1054,
     sqlState: '#42S22',
     sql: 'SELECT `id`, `userId`, `gameId`, `ticketsFrom`, `ticketsTo`, `items`, `createdAt`, `updatedAt`, `UserSteamID` FROM `classic_bets` AS `ClassicBet` WHERE `ClassicBet`.`gameId` = 12;' },

Why is Sequelize trying to take "UserSteamID" and why? This field is NOT in the model/migrations.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2017-07-02
@Alex_Wells

It turns out that this "wonderful" library pulls fields through the links that are declared in the User model.
Check other models and their connections.
Closed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question