diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2020-10-19 08:41:26 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2020-10-19 08:41:26 +0200 |
| commit | e575ae2c37359ab51b23ce44ccda4bb9bbfd3a5f (patch) | |
| tree | 742be49c60baa092ebc1c042af6838c18e3c9a1d | |
| parent | fe39072fc24e879034fb1e439fb0a47c7c66d4a2 (diff) | |
| download | sqlparse-e575ae2c37359ab51b23ce44ccda4bb9bbfd3a5f.tar.gz | |
Fix parsing of backticks (fixes #588).
The backticks in this operator regex was introduced in
c794c97531c09e66b6a7ffac76626a727ad02f5e. Pretty sure it was by mistake.
| -rw-r--r-- | CHANGELOG | 4 | ||||
| -rw-r--r-- | sqlparse/keywords.py | 2 | ||||
| -rw-r--r-- | tests/test_regressions.py | 7 |
3 files changed, 11 insertions, 2 deletions
@@ -1,7 +1,9 @@ Development Version ------------------- -Nothing yet. +Bug Fixes + +* Fix parsing of backticks (issue588). Release 0.4.1 (Oct 08, 2020) diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index a5deb93..c967b26 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -93,7 +93,7 @@ SQL_REGEX = { (r'[0-9_A-ZÀ-Ü][_$#\w]*', is_keyword), (r'[;:()\[\],\.]', tokens.Punctuation), (r'[<>=~!]+', tokens.Operator.Comparison), - (r'[+/@#%^&|`?^-]+', tokens.Operator), + (r'[+/@#%^&|^-]+', tokens.Operator), ]} FLAGS = re.IGNORECASE | re.UNICODE diff --git a/tests/test_regressions.py b/tests/test_regressions.py index b247ce2..38d1840 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -411,3 +411,10 @@ def test_format_invalid_where_clause(): # did raise ValueError formatted = sqlparse.format('where, foo', reindent=True) assert formatted == 'where, foo' + + +def test_splitting_at_and_backticks_issue588(): + splitted = sqlparse.split( + 'grant foo to user1@`myhost`; grant bar to user1@`myhost`;') + assert len(splitted) == 2 + assert splitted[-1] == 'grant bar to user1@`myhost`;' |
