fix: ignore unconverted ${} inside string literals #42
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.
Summary
This pull request fixes a false-positive error in
getStatement()where${}and#{}placeholders inside string literals (e.g.'path/to/${yyyymmdd}') were incorrectly treated as unconverted parameters.Problem
The original implementation scans the full SQL string for leftover placeholders and throws an error if any are found. However, this includes placeholders used inside string literals, which should not be substituted.
Example:
In this case, ${yyyymmdd} is a static part of the string and not intended to be replaced, but an error is thrown regardless.
Fix
The fix introduces a stripQuoted() function that removes all quoted segments from the SQL statement before checking for unconverted placeholders. This prevents false errors caused by ${} or #{} inside string literals.
Impact
Ensures string-literal ${} or #{} does not cause unexpected errors
Keeps the actual unconverted parameter detection intact
Backward compatible with existing behavior
Let me know if you'd like any refinements or test coverage added. I'm happy to iterate.