sidorares / sidorares/node-mysql2

Updating multiple columns with a javascript object

Open
#1,389 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Hello,

With node-mysql I was able to update multiple columns with this code, using a javascript object.

connection.query('update mytable set ? where id=?', [obj, obj.id], callback)

I just tried this query in node-mysql2 but this it fails with "Error: You have an error in your SQL syntax;". I am using the promisified API with connection.execute() (reason for switching to node-mysql2).

Am I missing something obvious, or is the "set ?" syntax not available ?

Thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the connection.execute() API and the query-formatting behavior used by node-mysql2, comparing it with the node-mysql example in the issue. Determine whether SET ? with an object is supported through execute(); done means confirming the supported behavior or documenting the required API usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, nodejs
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.