Skip to content

Conversation

@JangKroed
Copy link

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:

SELECT '/data/${yyyymmdd}/log' AS path

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.

function stripQuoted(text) {
  return text.replace(/(["'])(?:\\.|[^\\])*?\1/g, '');
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant