summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2016-09-14 18:42:22 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2016-09-14 18:42:22 +0200
commit4d05b441fcb801d320ac52ce90465b74d419ceac (patch)
tree0f18b1f401d1fce76be0d8403153e5616dbe573e /tests
parent4430c5c163d8b6ffc89d83b506c8a478037d26ea (diff)
downloadsqlparse-4d05b441fcb801d320ac52ce90465b74d419ceac.tar.gz
Add formatter option for comma first notation (fixes #141).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_format.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_format.py b/tests/test_format.py
index 023f26d..67377ab 100644
--- a/tests/test_format.py
+++ b/tests/test_format.py
@@ -322,6 +322,8 @@ class TestFormatReindent(object):
sqlparse.format('foo', reindent=True, wrap_after='foo')
with pytest.raises(SQLParseError):
sqlparse.format('foo', reindent=True, wrap_after=-12)
+ with pytest.raises(SQLParseError):
+ sqlparse.format('foo', reindent=True, comma_first='foo')
def test_stmts(self):
f = lambda sql: sqlparse.format(sql, reindent=True)
@@ -428,6 +430,19 @@ class TestFormatReindent(object):
'from table1, table2',
'where 1 = 2'])
+ def test_identifier_list_comment_first(self):
+ f = lambda sql: sqlparse.format(sql, reindent=True, comma_first=True)
+ # not the 3: It cleans up whitespace too!
+ s = 'select foo, bar, baz from table where foo in (1, 2,3)'
+ assert f(s) == '\n'.join([
+ 'select foo',
+ ' , bar',
+ ' , baz',
+ 'from table',
+ 'where foo in (1',
+ ' , 2',
+ ' , 3)'])
+
def test_identifier_list_with_functions(self):
f = lambda sql: sqlparse.format(sql, reindent=True)
s = ("select 'abc' as foo, coalesce(col1, col2)||col3 as bar,"