Skip to content

Commit

Permalink
Fix: allow $ to appear in postgres/redshift identifiers (#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored May 1, 2023
1 parent adc526c commit 6143491
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sqlglot/dialects/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ class Tokenizer(tokens.Tokenizer):
"$": TokenType.PARAMETER,
}

VAR_SINGLE_TOKENS = {"$"}

class Parser(parser.Parser):
STRICT_CAST = False

Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_postgres(self):
self.validate_identity("SELECT ARRAY[1, 2, 3] <@ ARRAY[1, 2]")
self.validate_identity("SELECT ARRAY[1, 2, 3] && ARRAY[1, 2]")
self.validate_identity("$x")
self.validate_identity("x$")
self.validate_identity("SELECT ARRAY[1, 2, 3]")
self.validate_identity("SELECT ARRAY(SELECT 1)")
self.validate_identity("SELECT ARRAY_LENGTH(ARRAY[1, 2, 3], 1)")
Expand Down
2 changes: 2 additions & 0 deletions tests/dialects/test_redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class TestRedshift(Validator):
def test_redshift(self):
self.validate_identity("SELECT * FROM #x")
self.validate_identity("SELECT INTERVAL '5 day'")
self.validate_identity("foo$")
self.validate_identity("$foo")

self.validate_all(
"SELECT SNAPSHOT",
Expand Down

0 comments on commit 6143491

Please sign in to comment.