summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2014-11-30 07:52:00 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2014-11-30 07:52:00 +0100
commit3d0bdf20c5f558258c08805a3ba546481d29ebac (patch)
treeb456207a067b8db3ce3872c7ae1ed7142d000c1a /sqlparse
parentbb3290c6f62a3020b49f4baf1049d1e2c55386df (diff)
downloadsqlparse-3d0bdf20c5f558258c08805a3ba546481d29ebac.tar.gz
Improved formatting when newline precedes commas in lists (fixes #140).
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/filters.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py
index 4a0b2c7..e576a26 100644
--- a/sqlparse/filters.py
+++ b/sqlparse/filters.py
@@ -246,6 +246,20 @@ class StripWhitespaceFilter:
token.value = ' '
last_was_ws = token.is_whitespace()
+ def _stripws_identifierlist(self, tlist):
+ # Removes newlines before commas, see issue140
+ last_nl = None
+ for token in tlist.tokens[:]:
+ if (token.ttype is T.Punctuation
+ and token.value == ','
+ and last_nl is not None):
+ tlist.tokens.remove(last_nl)
+ if token.is_whitespace():
+ last_nl = token
+ else:
+ last_nl = None
+ return self._stripws_default(tlist)
+
def _stripws_parenthesis(self, tlist):
if tlist.tokens[1].is_whitespace():
tlist.tokens.pop(1)