Skip to content

Commit 26b5385

Browse files
committed
Recognize USING as a keyword in 'USING(', not just in 'USING ('
These were previously caught by (r'[^\W\d_]\w*(?=[.(])', tokens.Name), so I added a special regex just above that one.
1 parent 9ab1464 commit 26b5385

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

sqlparse/lexer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class _Lexer(object):
187187
# IN is special, it may be followed by a parenthesis, but
188188
# is never a functino, see issue183
189189
(r'in\b(?=[ (])?', tokens.Keyword),
190+
(r'USING(?=\()', is_keyword),
190191
(r'[^\W\d_]\w*(?=[.(])', tokens.Name), # see issue39
191192
(r'[-]?0x[0-9a-fA-F]+', tokens.Number.Hexadecimal),
192193
(r'[-]?[0-9]*(\.[0-9]+)?[eE][-]?[0-9]+', tokens.Number.Float),

tests/test_grouping.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ def test_begin():
380380
assert isinstance(p.tokens[0], sql.Begin)
381381

382382

383+
def test_keyword_followed_by_parenthesis():
384+
p = sqlparse.parse('USING(somecol')[0]
385+
assert len(p.tokens) == 3
386+
assert p.tokens[0].ttype == T.Keyword
387+
assert p.tokens[1].ttype == T.Punctuation
388+
389+
383390
def test_nested_begin():
384391
p = sqlparse.parse('BEGIN foo BEGIN bar END END')[0]
385392
assert len(p.tokens) == 1

0 commit comments

Comments
 (0)