From 4c70aeaa2a8b1652553cc5a10bd593694cb3073f Mon Sep 17 00:00:00 2001 From: Adam Greenhall Date: Sat, 12 Sep 2015 00:56:58 -0700 Subject: Test: Subquery Ident-lists grouping alias bug Not being grouped correctly when aliased --- tests/test_grouping.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/test_grouping.py') diff --git a/tests/test_grouping.py b/tests/test_grouping.py index c35c61b..1971fb7 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -122,6 +122,16 @@ class TestGrouping(TestCaseBase): p = sqlparse.parse('(a, b, c)')[0] self.assert_(isinstance(p.tokens[0].tokens[1], sql.IdentifierList)) + @pytest.mark.xfail(strict=True) + def test_identifier_list_subquery(self): + """identifier lists should still work in subqueries with aliases""" + p = sqlparse.parse("""select * from (select a, b + c as d from table) sub""")[0] + subquery = p.tokens[-1].tokens[0] + iden_list = subquery.token_next_by_instance(0, sql.IdentifierList) + self.assert_(iden_list is not None) + # all the identifiers should be within the IdentifierList + self.assert_(subquery.token_next_by_instance(subquery.token_index(iden_list), sql.Identifier) is None) + def test_identifier_list_case(self): p = sqlparse.parse('a, case when 1 then 2 else 3 end as b, c')[0] self.assert_(isinstance(p.tokens[0], sql.IdentifierList)) -- cgit v1.2.1