Skip to content

Respect quoted parentheses when stripping query wrappers - #723

Open
pengpengyi92 wants to merge 1 commit into
macbre:masterfrom
pengpengyi92:fix/quoted-wrapper-parentheses-20261112
Open

pengpengyi92 wants to merge 1 commit into
macbre:masterfrom
pengpengyi92:fix/quoted-wrapper-parentheses-20261112

Conversation

@pengpengyi92

Copy link
Copy Markdown

_is_wrapped() currently counts parentheses inside quoted SQL text. For example,
Parser("((UPDATE t SET a = ')'))").tables raises InvalidQueryDefinition because
the redundant wrapper is not removed.

Count tokenizer parenthesis tokens instead of raw characters, using the existing
MySQL/T-SQL quoting markers where applicable. Leave lexically malformed input
untouched. No query execution, dialect-parser change or new dependency.

Added 31 cases covering INSERT/UPDATE/DELETE, one/two wrappers, escaped literals,
MySQL and T-SQL quoted names, and an unterminated literal. Initial regressions
failed before the production patch. Full suite: 323 passed, 100% coverage;
mypy sql_metadata and ruff check pass. Full-file formatter checks still report
pre-existing unrelated formatting differences, which are not included here.

AI-assisted with OpenAI Codex; no independent human review is claimed.

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