sidorares / sidorares/node-mysql2

namedPlaceholders with IN clause

Open
#196 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

It would be nice to have namedPlaceholders convert arrays of data into an IN clause.

I would like the following to be possible:

var parms = {
   keys: [1,2,3,4,5,6,7]
};

db.pool.execute('SELECT id FROM table WHERE id IN (:keys)', parms, function(res, err) {
});

It should execute to the following:

SELECT id FROM table WHERE id IN (?,?,?,?,?,?,?)

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 by tracing the namedPlaceholders handling in the mysql2 codebase and locating existing tests for parameter conversion. Check how array values are currently processed, then add coverage for the provided IN-clause example; done means the array expands to the shown number of placeholders while its values remain bound safely.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js, typescript
Domain
database
Issue type
Feature
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.