File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
131139def test_grouping_identifier_as_invalid ():
132140 # issue8
You can’t perform that action at this time.
0 commit comments