From 3f5ec21ffcd4702fc54b4a769224760ffbc31de9 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Sun, 21 Dec 2014 17:12:37 +0100 Subject: Improve formatting of HAVING statements. --- tests/test_format.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_format.py b/tests/test_format.py index b77b7a1..b789b17 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -326,3 +326,18 @@ def test_truncate_strings_invalid_option(): def test_truncate_strings_doesnt_truncate_identifiers(sql): formatted = sqlparse.format(sql, truncate_strings=2) assert formatted == sql + + +def test_having_produces_newline(): + sql = ( + 'select * from foo, bar where bar.id = foo.bar_id' + ' having sum(bar.value) > 100') + formatted = sqlparse.format(sql, reindent=True) + expected = [ + 'select *', + 'from foo,', + ' bar', + 'where bar.id = foo.bar_id', + 'having sum(bar.value) > 100' + ] + assert formatted == '\n'.join(expected) -- cgit v1.2.1