summaryrefslogtreecommitdiff
path: root/sqlparse/sql.py
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2015-02-08 16:52:15 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2015-02-08 16:52:15 +0100
commite1b5482b1413591260f41ceb50e97091928f195a (patch)
tree01ab00f4d38f20b37a2f75ef28f737da12baaa00 /sqlparse/sql.py
parent1ebad53c11295b26375fabf61591e7a69161842e (diff)
downloadsqlparse-e1b5482b1413591260f41ceb50e97091928f195a.tar.gz
(postgresql) Add support for square bracket array indexing, by darikg.
Pull request #170 with trivial conflicts resolved.
Diffstat (limited to 'sqlparse/sql.py')
-rw-r--r--sqlparse/sql.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 6174db0..c974b35 100644
--- a/sqlparse/sql.py
+++ b/sqlparse/sql.py
@@ -502,6 +502,13 @@ class Identifier(TokenList):
return None
return ordering.value.upper()
+ def get_array_indices(self):
+ """Returns an iterator of index expressions as strings"""
+
+ # 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)
+
class IdentifierList(TokenList):
"""A list of :class:`~sqlparse.sql.Identifier`\'s."""