Skip to content

Commit 9902b88

Browse files
John Bodleyandialbrecht
authored andcommitted
[fix] Addressing issue andialbrecht#507
1 parent e8ae45d commit 9902b88

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

sqlparse/keywords.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def is_keyword(value):
4848

4949
# FIXME(andi): VALUES shouldn't be listed here
5050
# see https://github.com/andialbrecht/sqlparse/pull/64
51-
# IN is special, it may be followed by a parenthesis, but
52-
# is never a function, see issue183
53-
(r'(CASE|IN|VALUES|USING|FROM)\b', tokens.Keyword),
51+
# AS and IN are special, it may be followed by a parenthesis, but
52+
# are never functions, see issue183 and issue507
53+
(r'(CASE|IN|VALUES|USING|FROM|AS)\b', tokens.Keyword),
5454

5555
(r'(@|##|#)[A-ZÀ-Ü]\w+', tokens.Name),
5656

tests/test_grouping.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ def test_grouping_identifier_invalid_in_middle():
127127
assert p[3].ttype == T.Whitespace
128128
assert str(p[2]) == 'foo.'
129129

130+
@pytest.mark.parametrize('s', ['foo as (select *)', 'foo as(select *)'])
131+
def test_grouping_identifer_as(s):
132+
# issue507
133+
p = sqlparse.parse(s)[0]
134+
assert isinstance(p.tokens[0], sql.Identifier)
135+
token = p.tokens[0].tokens[2]
136+
assert token.ttype == T.Keyword
137+
assert token.normalized == 'AS'
130138

131139
def test_grouping_identifier_as_invalid():
132140
# issue8

0 commit comments

Comments
 (0)