summaryrefslogtreecommitdiff
path: root/sqlparse/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlparse/sql.py')
-rw-r--r--sqlparse/sql.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 8492c5e..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):
@@ -542,6 +543,15 @@ class Parenthesis(TokenList):
return self.tokens[1:-1]
+class SquareBrackets(TokenList):
+ """Tokens between square brackets"""
+
+ __slots__ = ('value', 'ttype', 'tokens')
+
+ @property
+ def _groupable_tokens(self):
+ return self.tokens[1:-1]
+
class Assignment(TokenList):
"""An assignment like 'var := val;'"""
__slots__ = ('value', 'ttype', 'tokens')