diff options
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | sqlparse/lexer.py | 3 | ||||
| -rw-r--r-- | tests/test_format.py | 7 |
3 files changed, 11 insertions, 1 deletions
@@ -10,6 +10,8 @@ Bug Fixes reported by djo...@taket.org). * Split statements with IF as functions correctly (issue33, reported by charles....@unige.ch). + * Relax detection of keywords, esp. when used as function names + (issue36, nyuhu...@gmail.com). Release 0.1.2 (Nov 23, 2010) diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 6304911..507217a 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -172,10 +172,11 @@ class Lexer: (r':=', tokens.Assignment), (r'::', tokens.Punctuation), (r'[*]', tokens.Wildcard), + (r'CASE\b', tokens.Keyword), # extended CASE(foo) (r"`(``|[^`])*`", tokens.Name), (r"´(´´|[^´])*´", tokens.Name), (r'@[a-zA-Z_][a-zA-Z0-9_]+', tokens.Name), - (r'[a-zA-Z_][a-zA-Z0-9_]*(?=\.)', tokens.Name), # see issue39 + (r'[a-zA-Z_][a-zA-Z0-9_]*(?=[.(])', tokens.Name), # see issue39 (r'[<>=~!]+', tokens.Operator.Comparison), (r'[+/@#%^&|`?^-]+', tokens.Operator), (r'0x[0-9a-fA-F]+', tokens.Number.Hexadecimal), diff --git a/tests/test_format.py b/tests/test_format.py index f9740d5..e41b6b6 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -221,6 +221,13 @@ class TestFormatReindent(TestCaseBase): 'where (c1 = 1)', 'order by c1'])) + def test_keywordfunctions(self): # issue36 + f = lambda sql: sqlparse.format(sql, reindent=True) + s = 'select max(a) b, foo, bar' + self.ndiffAssertEqual(f(s), '\n'.join(['select max(a) b,', + ' foo,', + ' bar'])) + |
