Skip to content

Commit ab84201

Browse files
Georg Traarandialbrecht
authored andcommitted
allow operators to procede dollar quoted strings
1 parent f101546 commit ab84201

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Enhancements:
1414
Bug Fixes
1515

1616
* Ignore dunder attributes when creating Tokens (issue672).
17+
* Allow operators to precede dollar-quoted strings (issue763).
1718

1819

1920
Release 0.4.4 (Apr 18, 2023)

sqlparse/keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
(r"`(``|[^`])*`", tokens.Name),
3232
(r"´(´´|[^´])*´", tokens.Name),
33-
(r'((?<!\S)\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal),
33+
(r'((?<![\w\"\$])\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal),
3434

3535
(r'\?', tokens.Name.Placeholder),
3636
(r'%(\(\w+\))?s', tokens.Name.Placeholder),

tests/test_parse.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ def test_psql_quotation_marks():
180180
$PROC_2$ LANGUAGE plpgsql;""")
181181
assert len(t) == 2
182182

183+
# operators are valid infront of dollar quoted strings
184+
t = sqlparse.split("""UPDATE SET foo =$$bar;SELECT bar$$""")
185+
assert len(t) == 1
186+
187+
# identifiers must be separated by whitespace
188+
t = sqlparse.split("""UPDATE SET foo TO$$bar;SELECT bar$$""")
189+
assert len(t) == 2
190+
183191

184192
def test_double_precision_is_builtin():
185193
s = 'DOUBLE PRECISION'

0 commit comments

Comments
 (0)