Skip to content

Calling connection.query with an options object fails after a connection has been upgraded #59

Open
@angelsvirkov

Description

@angelsvirkov

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 for queryRow, queryHash, queryCol and queryKeyValue

To Reproduce

  1. Upgrade a connection
  2. Use the upgraded connection to query with query({sql: 'INSERT INTO ?? ..., values: [...]}, callbackFn)
  3. The values are getting replaced by an empty array so the resulting query inside of mysql 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions