diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-02-03 15:22:05 +0100 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-02-03 15:22:05 +0100 |
| commit | 4e8ae03682d346b2a57dc9d4760d838ec9674804 (patch) | |
| tree | 056c49cb7c8c6ca14a299748a3692dc6ee488e21 | |
| parent | c1b05d502b715558076e0d54008b846e27299d41 (diff) | |
| download | sqlparse-4e8ae03682d346b2a57dc9d4760d838ec9674804.tar.gz | |
Changed get_identifiers() to be a generator
| -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): |
