Skip to content

Commit

Permalink
Fix parsing of backticks (fixes #588).
Browse files Browse the repository at this point in the history
The backticks in this operator regex was introduced in
c794c97. Pretty sure it was by mistake.
  • Loading branch information
andialbrecht committed Oct 19, 2020
1 parent fe39072 commit e575ae2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Development Version
-------------------

Nothing yet.
Bug Fixes

* Fix parsing of backticks (issue588).


Release 0.4.1 (Oct 08, 2020)
Expand Down
2 changes: 1 addition & 1 deletion sqlparse/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def is_keyword(value):
(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
Expand Down
7 changes: 7 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`;'

0 comments on commit e575ae2

Please sign in to comment.