summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlparse/engine/grouping.py9
-rw-r--r--sqlparse/sql.py9
2 files changed, 10 insertions, 8 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index 73679e3..a317044 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -159,16 +159,17 @@ def group_identifier(tlist):
lambda y: (y.match(T.Punctuation, '.')
or y.ttype in (T.Operator,
T.Wildcard,
- T.ArrayIndex,
- T.Name)),
+ T.Name)
+ or isinstance(y, sql.SquareBrackets)),
lambda y: (y.ttype in (T.String.Symbol,
T.Name,
T.Wildcard,
- T.ArrayIndex,
T.Literal.String.Single,
T.Literal.Number.Integer,
T.Literal.Number.Float)
- or isinstance(y, (sql.Parenthesis, sql.Function)))))
+ or isinstance(y, (sql.Parenthesis,
+ sql.SquareBrackets,
+ sql.Function)))))
for t in tl.tokens[i:]:
# Don't take whitespaces into account.
if t.ttype is T.Whitespace:
diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 25d5243..9fcb546 100644
--- a/sqlparse/sql.py
+++ b/sqlparse/sql.py
@@ -511,11 +511,12 @@ class Identifier(TokenList):
return ordering.value.upper()
def get_array_indices(self):
- """Returns an iterator of index expressions as strings"""
+ """Returns an iterator of index token lists"""
- # Use [1:-1] index to discard the square brackets
- return (tok.value[1:-1] for tok in self.tokens
- if tok.ttype in T.ArrayIndex)
+ for tok in self.tokens:
+ if isinstance(tok, SquareBrackets):
+ # Use [1:-1] index to discard the square brackets
+ yield tok.tokens[1:-1]
class IdentifierList(TokenList):