summaryrefslogtreecommitdiff
path: root/sqlparse/sql.py
diff options
context:
space:
mode:
authorDarik Gamble <darik.gamble@gmail.com>2015-03-04 10:41:34 -0500
committerDarik Gamble <darik.gamble@gmail.com>2015-03-04 10:41:34 -0500
commitb61fe36f718ca4f7c0b4e8d1cb81cc1370877905 (patch)
tree4f8d9f55cd82a2d525082eab5c2f99e7d3ac8134 /sqlparse/sql.py
parenta93029f38fc2a1a182da92cf361d700cbe2b79c2 (diff)
downloadsqlparse-b61fe36f718ca4f7c0b4e8d1cb81cc1370877905.tar.gz
Group square-brackets into identifiers
Indentifier.get_array_indices() looks for square brackets, and yields lists of bracket grouped tokens as array indices
Diffstat (limited to 'sqlparse/sql.py')
-rw-r--r--sqlparse/sql.py9
1 files changed, 5 insertions, 4 deletions
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):