diff options
| author | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-02 19:22:08 +0200 |
|---|---|---|
| committer | Jesús Leganés Combarro "Piranna" <piranna@gmail.com> | 2012-06-02 19:22:08 +0200 |
| commit | 05fb6421329c85dc8afaf400a5df2186da1971e5 (patch) | |
| tree | 0269ae57f9f3e5432ae2ff7717b4647719b8a568 /sqlparse/engine | |
| parent | 56996812a9753fcf94117fd8c37eee60debeaf87 (diff) | |
| download | sqlparse-05fb6421329c85dc8afaf400a5df2186da1971e5.tar.gz | |
Fixed issue_50 (with some pending regressions)
Diffstat (limited to 'sqlparse/engine')
| -rw-r--r-- | sqlparse/engine/grouping.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 046ec9b..66ae807 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -209,9 +209,11 @@ 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) + # Search for the first identifier list start = None tcomma = tlist.token_next_match(0, T.Punctuation, ',') @@ -233,23 +235,25 @@ def group_identifier_list(tlist): if start == None: start = before - # Look if the next token is another comma - next_ = tlist.token_next(after) - if next_: - if next_.match(T.Punctuation, ','): - tcomma = next_ - continue + 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_ - elif(next_.ttype == T.Keyword - and next_.value.upper() not in ('FROM', 'WHERE', 'GROUP')): - tcomma = next_ - continue + 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) - # Skip ahead to next "," + # Skip ahead to next identifier list start = None tcomma = tlist.token_next_match(tlist.token_index(tcomma) + 1, T.Punctuation, ',') |
