FIX: False positive qmark detection for ? inside bracketed identifiers, string literals and comments by jahnvi480 · Pull Request #465 · microsoft/mssql-python
…, string literals, and comments
The parameter style detection used a naive '?' in sql check which falsely
flagged ? characters inside T-SQL bracketed identifiers ([q?marks]),
string literals ('is this ok?'), double-quoted identifiers, and SQL comments
as positional parameter placeholders.
Changes:
- Add _skip_quoted_context() helper to skip over SQL quoted contexts
(brackets, single/double quotes, single-line and multi-line comments)
- Add _has_unquoted_question_marks() that uses context-aware scanning
to only detect ? characters that are actual qmark placeholders
- Update detect_and_convert_parameters() to use the new context-aware check
- Add 40 new unit tests covering the helper functions and integration scenarios
Fixes: question mark in bracketed column name causes false positive
'Parameter style mismatch' error when using dict parameters.