diff options
| -rw-r--r-- | sqlparse/filters.py | 2 | ||||
| -rw-r--r-- | sqlparse/sql.py | 7 | ||||
| -rw-r--r-- | tests/test_grouping.py | 2 |
3 files changed, 6 insertions, 5 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 9aa3f6d..23d06e1 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -298,7 +298,7 @@ class ReindentFilter(Filter): self.offset -= num_offset def _process_identifierlist(self, tlist): - identifiers = tlist.get_identifiers() + identifiers = list(tlist.get_identifiers()) if len(identifiers) > 1 and not tlist.within(sql.Function): first = list(identifiers[0].flatten())[0] num_offset = self._get_offset(first) - len(first.value) diff --git a/sqlparse/sql.py b/sqlparse/sql.py index ddb85a1..1bc6b08 100644 --- a/sqlparse/sql.py +++ b/sqlparse/sql.py @@ -437,10 +437,11 @@ class IdentifierList(TokenList): def get_identifiers(self): """Returns the identifiers. - Whitespaces and punctuations are not included in this list. + Whitespaces and punctuations are not included in this generator. """ - return [x for x in self.tokens - if not x.is_whitespace() and not x.match(T.Punctuation, ',')] + for x in self.tokens: + if not x.is_whitespace() and not x.match(T.Punctuation, ','): + yield x class Parenthesis(TokenList): diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 5f060b9..8148d2f 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -181,7 +181,7 @@ class TestGrouping(TestCaseBase): self.assert_(isinstance(p.tokens[0], sql.Function)) p = sqlparse.parse('foo(null, bar)')[0] self.assert_(isinstance(p.tokens[0], sql.Function)) - self.assertEqual(len(p.tokens[0].get_parameters()), 2) + self.assertEqual(len(list(p.tokens[0].get_parameters())), 2) class TestStatement(TestCaseBase): |
