Incorrect arguments to mysqld_stmt_execute (MySQL 8.0.22)
See original GitHub issueHi, love this library!
Have been using it successfully across a large number of projects and it’s worked flawlessly for me so far. Just now I’ve seen that I have a single test case failing on the CI server (Gitlab), MySQL 8, failing with the following error:
VError: Failed executing query: \"SELECT * FROM message WHERE chat_id = ? ORDER BY sent DESC LIMIT ? OFFSET ?\" [01ensmg6m4dea0gh7gsjgaa5gb, 50, 0]: Incorrect arguments to mysqld_stmt_execute
at ConnectionPool.<anonymous> (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:128:27)
at Generator.throw (<anonymous>)
at rejected (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
caused by: Error: Incorrect arguments to mysqld_stmt_execute
at PromiseConnection.execute (/data/node_modules/mysql2/promise.js:110:22)
at ConnectionPool.<anonymous> (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:117:58)
at Generator.next (<anonymous>)
at fulfilled (/data/node_modules/@my-company/mysql-connection-pool/dist/ConnectionPool.js:5:58)
Now this error is wrapped by my own logic, but the cause I think it quite clear: Incorrect arguments to mysqld_stmt_execute
. The query being passed to the execute
method on the mysql2/promise
library is SELECT * FROM message WHERE chat_id = ? ORDER BY sent DESC LIMIT ? OFFSET ?
and the values are ["01ensmg6m4dea0gh7gsjgaa5gb", 50, 0]
. For some reason this only fails on the CI, and not locally on any of my (or my colleagues’) machines.
If I change this to query
instead of execute
, it works on the CI. If I form this query manually using the values that were passed-in, and run it, it also works.
Any idea what’s happening here? Is there some failure in how the parameters are being transferred to the MySQL service before being inserted?
EDIT 1: I’m also using v2.2.5 of the library
EDIT 2: Seems after the suggestions made here that the issue, at least for me, is only with mysql2 and MySQL server 8.0.22. 8.0.21 seems to work fine.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:42 (17 by maintainers)
mysql => 8.0.22 mysql2 => 2.2.5
const statement =
SELECT moment.id as id, moment.content as content, moment.createAt createTime, moment.updateAt updataTime, JSON_OBJECT('id', users.id, 'username', users.username) author FROM moment LEFT JOIN users ON moment.user_id = users.id LIMIT ? OFFSET ?;
connection.execute(statement, [size + “”, page + “”])
replace number with characters
@sidorares, just FYI, instead of passing javascript number type, if value is passed as “string” (even though column in int), it works!