Dev - #97
Merged
Merged
Conversation
_normalizeNamedParams() previously matched ":name" anywhere inside a
token, so it corrupted string literals ('literal :notparam text') and
misread the second ":" of a "::" cast as a parameter. Reworked it to use
an anchored per-token regex (a real ":name" reference is always isolated
as its own token by the tokenizer) plus a check for the preceding token
being a lone ":", and to substitute only the matched portion so any
leading whitespace merged into a token is preserved.
Also fixes a related bug this surfaced: a named param's index was
computed before confirming it would actually be registered, so a param
with no matching value in the params object silently reused its index
for the next distinct param, corrupting both in the generated SQL.
Adds unit test coverage for all of the above plus casts on literals,
chained casts, prefix collisions between param names, SQL-order vs
object-order indexing, case sensitivity, and the params-must-be-an-object
validation.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Same bug class as pg-connection: NAMED_PARAM_PATTERN matched ":name" anywhere inside a token instead of requiring the whole token to be one, so a string/double-quoted-identifier literal containing ":something" was corrupted - the entire token was replaced with "@something", discarding everything else in it. T-SQL also has its own gap Postgres doesn't: "[bracket]" quoted identifiers aren't a "quote" character the tokenizer recognizes, so "[col:name]" comes back as three separate tokens ("[col", ":name", "]"). Added explicit bracket-depth tracking so a ":name" inside one is left alone. Adds unit test coverage for both, plus multiple/repeated params, the no-named-param no-op case, and that the params object itself is never rewritten (mssql binds by name via request.input(), unlike postgres's positional rebuild). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.