summaryrefslogtreecommitdiff
path: root/sqlparse/sql.py
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2015-03-05 12:00:32 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2015-03-05 12:00:32 +0100
commite038a06f0c92a9aec95c9771bae22fb5e8f16432 (patch)
treeb13ae4c310a30beac7b021c8a359081883f5e799 /sqlparse/sql.py
parent9cec0cde3818005d70b0473f3c99241f5df68394 (diff)
parentd02a952b7c3f9a01c40630b6bf7699c1e9c95e21 (diff)
downloadsqlparse-e038a06f0c92a9aec95c9771bae22fb5e8f16432.tar.gz
Merge master into v0.2.0.
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 367204d..89d1059 100644
--- a/sqlparse/sql.py
+++ b/sqlparse/sql.py
@@ -504,11 +504,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):
@@ -535,6 +536,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')