diff options
author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-03 02:01:33 +0200 |
---|---|---|
committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-03 02:01:33 +0200 |
commit | c879535d316bfd914a89ce810b2926e4004121b9 (patch) | |
tree | b18a23f6eed4f6dcc60e3cdb1a48f468732127e0 | |
parent | 05fb6421329c85dc8afaf400a5df2186da1971e5 (diff) | |
download | sqlparse-c879535d316bfd914a89ce810b2926e4004121b9.tar.gz |
Started new design for group_identifier_list()
-rw-r--r-- | sqlparse/engine/grouping.py | 26 | ||||
-rw-r--r-- | tests/test_format.py | 1 |
2 files changed, 17 insertions, 10 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 66ae807..7dfc219 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -209,7 +209,6 @@ def group_identifier_list(tlist): """ Create and group the identifiers list """ - print "group_identifierlist", start, after tokens = tlist.tokens_between(start, after) return tlist.group_tokens(sql.IdentifierList, tokens) @@ -235,20 +234,27 @@ def group_identifier_list(tlist): if start == None: start = before - def continue_next(): # Check the next token next_ = tlist.token_next(after) while next_: - # Next token is another comma or an identifier list keyword - if next_.match(T.Punctuation, ','): - return next_ - +# # Next token is another comma or an identifier list keyword +# if next_.match(T.Punctuation, ','): +# return next_ +# +# next_ = tlist.token_next(next_) + + passed = False + for func in fend1_funcs: + if func(next_): + passed = True + break + + if not passed: + break + + after = next_ next_ = tlist.token_next(next_) - tcomma = continue_next() - if tcomma: - continue - # Reached the end of the list # Create and group the identifiers list tcomma = group_identifierlist(start, after) diff --git a/tests/test_format.py b/tests/test_format.py index 0ec2192..c614fce 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -161,6 +161,7 @@ class TestFormatReindent(TestCaseBase): def test_identifier_list(self): f = lambda sql: sqlparse.format(sql, reindent=True) s = 'select foo, bar, baz from table1, table2 where 1 = 2' + print f(s) self.ndiffAssertEqual(f(s), '\n'.join(['select foo,', ' bar,', ' baz', |