Skip to content

fix: allow named parameters to start with underscore - #59

Draft
harinarayansharma140 wants to merge 4 commits into
mysqljs:masterfrom
harinarayansharma140:master
Draft

fix: allow named parameters to start with underscore#59
harinarayansharma140 wants to merge 4 commits into
mysqljs:masterfrom
harinarayansharma140:master

Conversation

@harinarayansharma140

Copy link
Copy Markdown
Contributor

Updated RE_PARAM regex to support parameter names beginning with underscore (_), such as :_start, :_limit, :_offset, etc.

Previously, the regex pattern [a-zA-Z][a-zA-Z0-9_]* required the first character to be a letter. This prevented valid parameter names like :_start from being recognized.

Changed pattern to [a-zA-Z_][a-zA-Z0-9_]* to allow underscore as the first character, matching common SQL parameter naming conventions used by many database drivers and ORMs.

This change maintains backward compatibility while extending support for a wider range of valid parameter names.

Updated RE_PARAM regex to support parameter names beginning with
underscore (_), such as :_start, :_limit, :_offset, etc.

Previously, the regex pattern [a-zA-Z][a-zA-Z0-9_]* required the
first character to be a letter. This prevented valid parameter
names like :_start from being recognized.

Changed pattern to [a-zA-Z_][a-zA-Z0-9_]* to allow underscore
as the first character, matching common SQL parameter naming
conventions used by many database drivers and ORMs.

This change maintains backward compatibility while extending
support for a wider range of valid parameter names.
@wellwelwel wellwelwel changed the title Allow named parameters to start with underscore fix: allow named parameters to start with underscore Dec 23, 2025
@wellwelwel

Copy link
Copy Markdown
Member

@wellwelwel wellwelwel linked an issue Dec 23, 2025 that may be closed by this pull request
Comment thread test/example.js
[123, 'admin'],
]);

query =

@wellwelwel wellwelwel Dec 23, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that a test mixing one parameter that starts with _ and another that doesn't, is a good scenario to include in the tests to ensure that there are no conflicts when combining uses 🙋🏻‍♂️

Comment thread test/example.js
@wellwelwel
wellwelwel marked this pull request as draft February 17, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does not accept placeholder names that begin with underscore ('_')

3 participants