summaryrefslogtreecommitdiff
path: root/sqlparse/engine
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2015-12-07 19:48:32 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2015-12-08 10:58:45 +0100
commitbd3ef1c518b99851fb9f0c1ead0ffc70f445f192 (patch)
tree4e8c18c087367cc81c14e7ff161ad6bcf189979d /sqlparse/engine
parentcded58e3dbd7fc1e4dfb250d07c28662eafc32ed (diff)
downloadsqlparse-bd3ef1c518b99851fb9f0c1ead0ffc70f445f192.tar.gz
Workaround to avoid IndexError when grouping identifiers.
Diffstat (limited to 'sqlparse/engine')
-rw-r--r--sqlparse/engine/grouping.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index c8c2415..bb1f0b0 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -232,7 +232,6 @@ def group_identifier(tlist):
def group_identifier_list(tlist):
[group_identifier_list(sgroup) for sgroup in tlist.get_sublists()
if not isinstance(sgroup, sql.IdentifierList)]
- idx = 0
# Allowed list items
fend1_funcs = [lambda t: isinstance(t, (sql.Identifier, sql.Function,
sql.Case)),
@@ -249,10 +248,11 @@ def group_identifier_list(tlist):
lambda t: isinstance(t, sql.Comment),
lambda t: t.ttype == T.Comment.Multiline,
]
- tcomma = tlist.token_next_match(idx, T.Punctuation, ',')
+ tcomma = tlist.token_next_match(0, T.Punctuation, ',')
start = None
while tcomma is not None:
- idx = tlist.token_index(tcomma, start=idx)
+ # Go back one idx to make sure to find the correct tcomma
+ idx = tlist.token_index(tcomma)
before = tlist.token_prev(idx)
after = tlist.token_next(idx)
# Check if the tokens around tcomma belong to a list