From f0754a6b6540e37c8aa270975194101024d4b2f8 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Sat, 1 Oct 2016 14:07:52 +0200 Subject: Handle operator grouping after identifying typecasts (fixes #297). --- tests/test_grouping.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 655ef0f..20151a1 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -64,6 +64,20 @@ def test_grouping_identifiers(): assert identifiers[0].get_alias() == "col" +@pytest.mark.parametrize('s', [ + 'foo, bar', + 'sum(a), sum(b)', + 'sum(a) as x, b as y', + 'sum(a)::integer, b', + 'sum(a)/count(b) as x, y', + 'sum(a)::integer as x, y', + 'sum(a)::integer/count(b) as x, y', # issue297 +]) +def test_group_identifier_list(s): + parsed = sqlparse.parse(s)[0] + assert isinstance(parsed.tokens[0], sql.IdentifierList) + + def test_grouping_identifier_wildcard(): p = sqlparse.parse('a.*, b.id')[0] assert isinstance(p.tokens[0], sql.IdentifierList) -- cgit v1.2.1