Repository navigation
Keep doubled quote escapes within one generalized SQL literal - #705
Merged
Merged
Conversation
macbre
approved these changes
Oct 20, 2026
macbre
enabled auto-merge (squash)
October 20, 2026 16:10
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.
Parser("SELECT 'O''Reilly'").generalizecurrently returnsSELECT XX, while an ordinary string returnsSELECT X. One SQL literal is split at its doubled quote escapes, so equivalent query shapes can end up in different groups.LIKEhas the same problem.Use the existing sqlglot tokenizer to replace complete string tokens before collapsing LIKE clauses. Preserve
N/nprefixes and the previous best-effort fallback when tokenization fails. Queries without single quotes skip the added tokenizer pass; queries with literals incur that extra pass.Added 14 cases covering doubled quotes in SELECT, national strings and LIKE, separate literals, and unterminated input. Against the original implementation, 13 fail and the malformed-input control passes. After the change, the full suite passes: 290 tests, 100% coverage. Mypy, Ruff, formatting and diff checks pass on Python 3.13/macOS arm64. No dependencies changed.
Prepared and tested with OpenAI Codex; not human-reviewed before submission.