unicode fix#7904
Closed
stwala wants to merge 1 commit into
Closed
Conversation
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.
Fix Postgres Unicode escape string literals (U&'...') being corrupted during parsing and regeneration. Today U&'\FE01' tokenizes as the identifier U followed by the & operator, so round-tripping through sqlglot.transpile(sql, read="postgres", write="postgres") turns it into U & '\FE01', which changes the SQL on round-trip. The Postgres tokenizer should recognize U&'...' (case-insensitive U, immediately followed by &, no space) as a single unicode-escape string literal. Escape sequences inside use a leading backslash followed by either a 4-digit or 6-digit hex code point (\FE01, +01F600). An optional UESCAPE '' clause after the closing quote can override the default escape character; doubling the escape character inside the literal represents that character itself. Parsing and regenerating one of these literals must preserve the U&'...' form (and its UESCAPE clause, if present) rather than splitting it into separate tokens