Skip to content

Commit

Permalink
Fix(redshift): treat single quote as an escape character (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored Oct 3, 2023
1 parent 5b0df93 commit a270c15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlglot/dialects/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _parse_convert(self, strict: bool) -> t.Optional[exp.Expression]:
class Tokenizer(Postgres.Tokenizer):
BIT_STRINGS = []
HEX_STRINGS = []
STRING_ESCAPES = ["\\"]
STRING_ESCAPES = ["\\", "'"]

KEYWORDS = {
**Postgres.Tokenizer.KEYWORDS,
Expand Down
5 changes: 5 additions & 0 deletions tests/dialects/test_redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class TestRedshift(Validator):
dialect = "redshift"

def test_redshift(self):
self.validate_identity(
"SELECT 'a''b'",
"SELECT 'a\\'b'",
)

self.validate_all(
"x ~* 'pat'",
write={
Expand Down

0 comments on commit a270c15

Please sign in to comment.