From 9ab51d65524f3816a705fdd98a8aed60ad38fe5c Mon Sep 17 00:00:00 2001 From: Victor Uriarte Date: Tue, 7 Jun 2016 22:16:51 -0700 Subject: Remove redundant token no point in returning tk to remove it right after --- sqlparse/filters/reindent.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'sqlparse') diff --git a/sqlparse/filters/reindent.py b/sqlparse/filters/reindent.py index 8b3f7fa..994f0aa 100644 --- a/sqlparse/filters/reindent.py +++ b/sqlparse/filters/reindent.py @@ -27,9 +27,9 @@ class ReindentFilter(object): token = next(token.flatten()) for t in self._curr_stmt.flatten(): - yield t if t == token: raise StopIteration + yield t def _get_offset(self, token): raw = ''.join(map(text_type, self._flatten_up_to_token(token))) @@ -100,14 +100,13 @@ class ReindentFilter(object): with indent(self, 1 if is_DML_DLL else 0): tlist.tokens.insert(0, self.nl()) if is_DML_DLL else None - with offset(self, self._get_offset(first)): # +1 from ( removed + with offset(self, self._get_offset(first) + 1): self._process_default(tlist, not is_DML_DLL) def _process_identifierlist(self, tlist): identifiers = list(tlist.get_identifiers()) first = next(identifiers.pop(0).flatten()) - num_offset = 1 if self.char == '\t' else (self._get_offset(first) - - len(first.value)) + num_offset = 1 if self.char == '\t' else self._get_offset(first) if not tlist.within(sql.Function): with offset(self, num_offset): position = 0 @@ -124,8 +123,8 @@ class ReindentFilter(object): cond, _ = next(iterable) first = next(cond[0].flatten()) - with offset(self, self._get_offset(tlist[0]) - len(tlist[0].value)): - with offset(self, self._get_offset(first) - len(first.value)): + with offset(self, self._get_offset(tlist[0])): + with offset(self, self._get_offset(first)): for cond, value in iterable: token = value[0] if cond is None else cond[0] tlist.insert_before(token, self.nl()) -- cgit v1.2.1