Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
angelsvirkov opened this issue Sep 30, 2021 · 0 comments
Labels

Comments

@angelsvirkov
Copy link

angelsvirkov commented Sep 30, 2021

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
angelsvirkov added a commit to angelsvirkov/node-mysql-utilities that referenced this issue Oct 22, 2021
- Issue: Calling `connection.query` with an options object fails after a connection has been upgraded tshemsedinov#59
angelsvirkov added a commit to angelsvirkov/node-mysql-utilities that referenced this issue Oct 22, 2021
- Calling `connection.query` with an options object fails after a connection has been upgraded tshemsedinov#59
angelsvirkov added a commit to angelsvirkov/node-mysql-utilities that referenced this issue Oct 22, 2021
- Issue: Calling `connection.query` with an options object fails after a connection has been upgraded tshemsedinov#59
@angelsvirkov angelsvirkov mentioned this issue Oct 22, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant