From 113897280c612aa839fa9f8bd44bfd720d3729c7 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Sat, 29 Jul 2017 10:16:34 +0200 Subject: Fix parsing of UNION ALL after WHERE (fixes #349). --- tests/test_grouping.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 76ba651..1f3a19e 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -216,6 +216,15 @@ def test_grouping_where(): assert isinstance(p.tokens[-1].tokens[0].tokens[-2], sql.Where) +@pytest.mark.parametrize('s', ( + 'select 1 where 1 = 2 union select 2', + 'select 1 where 1 = 2 union all select 2', +)) +def test_grouping_where_union(s): + p = sqlparse.parse(s)[0] + assert p.tokens[5].value.startswith('union') + + def test_returning_kw_ends_where_clause(): s = 'delete from foo where x > y returning z' p = sqlparse.parse(s)[0] -- cgit v1.2.1