fix(e6): escape lone apostrophes in literals under FIX_QUOTE_ESCAPES#256
Merged
tkaunlaky-e6 merged 3 commits intoMay 11, 2026
Merged
Conversation
…s on Under FIX_QUOTE_ESCAPES, the E6 generator's escape_str override was unconditionally skipping the single-quote escape pass. That is correct for Variant C literals (parser-merged adjacent strings with '' embedded in Literal.this), but it breaks literals whose text contains a lone apostrophe — e.g. Databricks double-quoted strings like "SCARLET'S WALK (2023 REMASTER)", which the tokenizer extracts as a single-quoted literal value with one ' in the text. With the override skipping the escape, the apostrophe goes out raw and terminates the output string early, producing invalid E6. Gate the override on the presence of '' in the literal: when '' is not in the text, defer to the base Generator.escape_str (which correctly replaces ' with \') and only apply the existing skip-escape behavior when '' is actually present (the case the override was designed for).
ArnavBorkar
approved these changes
May 11, 2026
ArnavBorkar
approved these changes
May 11, 2026
aravindh-e6x
approved these changes
May 11, 2026
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.
Summary
Kantar's INSERT queries containing Databricks double-quoted strings with an apostrophe inside — e.g.
"SCARLET'S WALK (2023 REMASTER)"— were emitting invalid E6 with the apostrophe unescaped. The bare'terminated the output string literal early.The E6 generator's
escape_stroverride atsqlglot/dialects/e6.pyunconditionally skipped the single-quote escape pass underFIX_QUOTE_ESCAPES=true. That is correct only for Variant C literals (parser-merged adjacent string tokens with''embedded inLiteral.this). For literals whose text contains a lone'(Databricks"..."strings, or\'escapes the tokenizer consumed), the override produced raw apostrophes in output.Fix
Gate the override on whether
''is actually present in the literal text. When''is not in the text, defer to the baseGenerator.escape_str, which correctly replaces'with\'since E6'sSTRING_ESCAPES = ['\\']. When''is present, retain the existing behavior —''passes through unchanged, no\'introduced.Behavior
"SCARLET'S WALK"(Kantar)SCARLET'S WALK'SCARLET\'S WALK''ROCKIN'' AROUND'ROCKIN'' AROUND'ROCKIN'' AROUND''Côte d''''Azur'Côte d''''Azur'Côte d''''Azur'Test plan
test_fix_quote_escapescontinues to pass (4 cases — all literals contain'', take the unchanged path).FIX_QUOTE_ESCAPES=trueon Kantar's exact query.