diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2016-10-24 20:45:43 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2016-10-24 20:45:43 +0200 |
| commit | e0970cc54af6e441aabfea602e412428d02b7374 (patch) | |
| tree | d4f8a7daa4251abd6081d96032d1c0dfccb223a7 /tests | |
| parent | b68e4b781b8d74b0222411e83a16408a83cde7d6 (diff) | |
| download | sqlparse-e0970cc54af6e441aabfea602e412428d02b7374.tar.gz | |
Fix an edge-case with subselects in CASE clauses.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_grouping.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 20151a1..02d211e 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -250,6 +250,16 @@ def test_grouping_alias_case(): assert p.tokens[0].get_alias() == 'foo' +def test_grouping_subquery_no_parens(): + # Not totally sure if this is the right approach... + # When a THEN clause contains a subquery w/o parens around it *and* + # a WHERE condition, the WHERE grouper consumes END too. + # This takes makes sure that it doesn't fail. + p = sqlparse.parse('CASE WHEN 1 THEN select 2 where foo = 1 end')[0] + assert len(p.tokens) == 1 + assert isinstance(p.tokens[0], sql.Case) + + def test_grouping_alias_returns_none(): # see issue185 p = sqlparse.parse('foo.bar')[0] |
