summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2016-10-24 20:45:43 +0200
committerAndi Albrecht <albrecht.andi@gmail.com>2016-10-24 20:45:43 +0200
commite0970cc54af6e441aabfea602e412428d02b7374 (patch)
treed4f8a7daa4251abd6081d96032d1c0dfccb223a7 /sqlparse
parentb68e4b781b8d74b0222411e83a16408a83cde7d6 (diff)
downloadsqlparse-e0970cc54af6e441aabfea602e412428d02b7374.tar.gz
Fix an edge-case with subselects in CASE clauses.
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/filters/reindent.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sqlparse/filters/reindent.py b/sqlparse/filters/reindent.py
index ff1b211..bf1f139 100644
--- a/sqlparse/filters/reindent.py
+++ b/sqlparse/filters/reindent.py
@@ -162,7 +162,8 @@ class ReindentFilter(object):
with offset(self, len("WHEN ")):
self._process_default(tlist)
end_idx, end = tlist.token_next_by(m=sql.Case.M_CLOSE)
- tlist.insert_before(end_idx, self.nl())
+ if end_idx is not None:
+ tlist.insert_before(end_idx, self.nl())
def _process_default(self, tlist, stmts=True):
self._split_statements(tlist) if stmts else None