diff options
author | Andi Albrecht <albrecht.andi@gmail.com> | 2019-06-26 12:35:02 +0200 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2019-06-26 12:35:02 +0200 |
commit | 5a3164d8db9ce5bbd64480bcb63eb1ac7a587151 (patch) | |
tree | 1ac2807dc63ff41c6098e602b8edd88d638368ba | |
parent | 1f7edabb94ddf143b61643f681eb179d8431c4bf (diff) | |
download | sqlparse-5a3164d8db9ce5bbd64480bcb63eb1ac7a587151.tar.gz |
Optimize parsing of literal blocks between dollar signs (fixes #491).
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | sqlparse/keywords.py | 2 |
2 files changed, 3 insertions, 1 deletions
@@ -11,6 +11,8 @@ Bug Fixes * Fix splitting of SQL with multiple statements inside parentheses (issue485, pr486 by win39). * Correctly identify NULLS FIRST / NULLS LAST as keywords (issue487). +* Fix splitting of SQL statements that contain dollar signs in + identifiers (issue491). Release 0.3.0 (Mar 11, 2019) diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index 2444b22..5c47dfc 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -38,7 +38,7 @@ SQL_REGEX = { (r"`(``|[^`])*`", tokens.Name), (r"´(´´|[^´])*´", tokens.Name), - (r'(\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal), + (r'((?<!\S)\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal), (r'\?', tokens.Name.Placeholder), (r'%(\(\w+\))?s', tokens.Name.Placeholder), |