summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlparse/filters.py7
-rw-r--r--tests/test_format.py5
2 files changed, 10 insertions, 2 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py
index 91258ff..f1163ca 100644
--- a/sqlparse/filters.py
+++ b/sqlparse/filters.py
@@ -4,6 +4,7 @@ import re
from sqlparse.engine import grouping
from sqlparse import tokens as T
+from sqlparse import sql
class Filter(object):
@@ -171,8 +172,10 @@ class ReindentFilter(Filter):
if prev and prev.is_whitespace():
tlist.tokens.pop(tlist.token_index(prev))
offset += 1
- if prev and (str(prev).endswith('\n')
- or str(prev).endswith('\r')):
+ if (prev
+ and isinstance(prev, sql.Comment)
+ and (str(prev).endswith('\n')
+ or str(prev).endswith('\r'))):
nl = tlist.token_next(token)
else:
nl = self.nl()
diff --git a/tests/test_format.py b/tests/test_format.py
index 9b296a3..7cfb7fe 100644
--- a/tests/test_format.py
+++ b/tests/test_format.py
@@ -169,5 +169,10 @@ class TestFormatReindent(TestCaseBase):
self.ndiffAssertEqual(f(s), '\n'.join(['select c1',
'from foo',
'order by c1']))
+ s = 'select c1 from t1 where (c1 = 1) order by c1'
+ self.ndiffAssertEqual(f(s), '\n'.join(['select c1',
+ 'from t1',
+ 'where (c1 = 1)',
+ 'order by c1']))