File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ Bug Fixes
1111* Fix parsing of incomplete AS (issue284, by vmuriart).
1212* Fix parsing of Oracle names containing dollars (issue291).
1313* Fix parsing of UNION ALL (issue294).
14+ * Fix grouping of identifiers containing typecasts (issue297).
1415
1516Internal Changes
1617
Original file line number Diff line number Diff line change @@ -343,9 +343,9 @@ def group(stmt):
343343 group_period ,
344344 group_arrays ,
345345 group_identifier ,
346- group_operator ,
347346 group_order ,
348347 group_typecasts ,
348+ group_operator ,
349349 group_as ,
350350 group_aliased ,
351351 group_assignment ,
Original file line number Diff line number Diff line change @@ -64,6 +64,20 @@ def test_grouping_identifiers():
6464 assert identifiers [0 ].get_alias () == "col"
6565
6666
67+ @pytest .mark .parametrize ('s' , [
68+ 'foo, bar' ,
69+ 'sum(a), sum(b)' ,
70+ 'sum(a) as x, b as y' ,
71+ 'sum(a)::integer, b' ,
72+ 'sum(a)/count(b) as x, y' ,
73+ 'sum(a)::integer as x, y' ,
74+ 'sum(a)::integer/count(b) as x, y' , # issue297
75+ ])
76+ def test_group_identifier_list (s ):
77+ parsed = sqlparse .parse (s )[0 ]
78+ assert isinstance (parsed .tokens [0 ], sql .IdentifierList )
79+
80+
6781def test_grouping_identifier_wildcard ():
6882 p = sqlparse .parse ('a.*, b.id' )[0 ]
6983 assert isinstance (p .tokens [0 ], sql .IdentifierList )
You can’t perform that action at this time.
0 commit comments