sidorares / sidorares/node-mysql2
Comments with a single apostrophe in queries with parameters raise a syntax error
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
The error raised is:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':id' at line {insert_line_here}
🔴 Failing Case 1
Simple example
SELECT id
FROM users
WHERE
-- This comment with a single ' will break the parameter below it
id = :id;
🔴 Failing Case 2
Adding additional elements to the query does not affect it
SELECT id
FROM users
WHERE
username = "you" AND
-- This comment with a single ' will break the parameter below it
id = :id;
🔴 Failing Case 3
The minimum example
SELECT id
FROM users
WHERE
-- '
id = :id;
🔴 Failing Case 4
The quote does not need to be right before the parameter
-- '
SELECT id
FROM users
WHERE
id = :id;
💚 Passing Case 1
Replace parameter with a literal value
SELECT id
FROM users
WHERE
-- '
id = 1;
💚 Passing Case 2
Close the single quote
SELECT id
FROM users
WHERE
-- ''
id = :id;
💚 Passing Case 3
Move the quote after the parameter
SELECT id
FROM users
WHERE
id = :id;
-- '
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named in the issue. Start by reproducing the parameterized queries shown in the report and trace how SQL comments and named parameters are processed. Done means a single apostrophe in a comment no longer causes a syntax error while the listed passing and failing cases behave as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100