Open
Description
Describe the bug
If a query connection has been upgraded, the corresponding query override function does not support all signatures of the initial query function. More specifically the third query signature form, is not working. This is the form which uses .query(options, callback)
.
- I believe this bug is available not only for
query
but also forqueryRow
,queryHash
,queryCol
andqueryKeyValue
To Reproduce
- Upgrade a connection
- Use the upgraded connection to query with
query({sql: 'INSERT INTO ?? ..., values: [...]}, callbackFn)
- The
values
are getting replaced by an empty array so the resulting query inside ofmysql
is malformed.
Expected behavior
Expected the upgraded connection.query
to work with the function signature form, which looks like query(optionsObj, callbackFn)
mysql
- 2.18.1- Other system versions are irrelevant
Additional context
- The problem lies in the fact that the override function replaces the current values with empty array over here
- Whenever the first argument of the query is an object, the mysql package expects that the second argument is a function or else it would override the existing values from the object as implemented here. Since the override of mysql-utilities passes an empty array to the original mysql query, the latter is going to override the existing values leading to a malformed SQL because it cannot be properly formatted.
- I will try to submit a PR to fix this -> Fix/query signature #60