-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat!: add support for heredoc strings (Postgres, ClickHouse) #2328
Conversation
@@ -248,11 +248,10 @@ class Postgres(Dialect): | |||
} | |||
|
|||
class Tokenizer(tokens.Tokenizer): | |||
QUOTES = ["'", "$$"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was incorrect before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more like partially correct; it didn't take into account tagged heredocs like the following:
georgesittas=# select $foo$this is a string$foo$;
?column?
------------------
this is a string
(1 row)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI the relevant commit is https://github.com/tobymao/sqlglot/pull/617/files, cc @mpf82
@@ -207,7 +207,6 @@ 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("SELECT ARRAY[1, 2, 3] && ARRAY[1, 2]") | |||
self.validate_identity("$x") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is invalid postgres:
georgesittas=# select $x;
ERROR: syntax error at or near "$"
LINE 1: select $x;
@@ -226,7 +226,6 @@ def test_identity(self): | |||
self.validate_identity("SELECT * FROM #x") | |||
self.validate_identity("SELECT INTERVAL '5 day'") | |||
self.validate_identity("foo$") | |||
self.validate_identity("$foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, works fine for my use case. Thanks! |
Fixes #2316 - planning to do another pass on this and double-check some changed tests etc.
cc: @pkit
References: