summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Greenhall <agreenhall@lyft.com>2015-09-12 00:56:58 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-06 06:31:35 -0700
commit4c70aeaa2a8b1652553cc5a10bd593694cb3073f (patch)
tree92f420ec00a748d0d72f5b73c269b8adb2cb2063
parent74faef72d8e136a37bec93cc688817c97d162482 (diff)
downloadsqlparse-4c70aeaa2a8b1652553cc5a10bd593694cb3073f.tar.gz
Test: Subquery Ident-lists grouping alias bug
Not being grouped correctly when aliased
-rw-r--r--tests/test_grouping.py10
1 files changed, 10 insertions, 0 deletions
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))