summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlparse/engine/grouping.py7
-rw-r--r--sqlparse/sql.py4
2 files changed, 7 insertions, 4 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index a317044..b30e564 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -188,9 +188,12 @@ def group_identifier(tlist):
t1 = tl.token_next_by_type(
i, (T.String.Symbol, T.Name, T.Literal.Number.Integer,
T.Literal.Number.Float))
- t2 = tl.token_next_by_instance(i, (sql.Function, sql.Parenthesis))
+
+ i1 = tl.token_index(t1) if t1 else None
+ t2_end = None if i1 is None else i1 + 1
+ t2 = tl.token_next_by_instance(i, (sql.Function, sql.Parenthesis), end=t2_end)
+
if t1 and t2:
- i1 = tl.token_index(t1)
i2 = tl.token_index(t2)
if i1 > i2:
return t2
diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 5ecfbdc..f965f03 100644
--- a/sqlparse/sql.py
+++ b/sqlparse/sql.py
@@ -256,7 +256,7 @@ class TokenList(Token):
continue
return token
- def token_next_by_instance(self, idx, clss):
+ def token_next_by_instance(self, idx, clss, end=None):
"""Returns the next token matching a class.
*idx* is where to start searching in the list of child tokens.
@@ -267,7 +267,7 @@ class TokenList(Token):
if not isinstance(clss, (list, tuple)):
clss = (clss,)
- for token in self.tokens[idx:]:
+ for token in self.tokens[idx:end]:
if isinstance(token, clss):
return token