summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/engine/grouping.py2
-rw-r--r--sqlparse/sql.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index d30031f..a03c0b4 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -231,7 +231,7 @@ def group_where(tlist):
tidx = tlist.token_index(token)
end = tlist.token_next_match(tidx+1, T.Keyword, stopwords)
if end is None:
- end = tlist.tokens[-1]
+ end = tlist._groupable_tokens[-1]
else:
end = tlist.tokens[tlist.token_index(end)-1]
group = tlist.group_tokens(Where, tlist.tokens_between(token, end))
diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 5969841..195696e 100644
--- a/sqlparse/sql.py
+++ b/sqlparse/sql.py
@@ -176,6 +176,10 @@ class TokenList(Token):
def get_sublists(self):
return [x for x in self.tokens if isinstance(x, TokenList)]
+ @property
+ def _groupable_tokens(self):
+ return self.tokens
+
def token_first(self, ignore_whitespace=True):
"""Returns the first child token.
@@ -426,6 +430,10 @@ class Parenthesis(TokenList):
"""Tokens between parenthesis."""
__slots__ = ('value', 'ttype', 'tokens')
+ @property
+ def _groupable_tokens(self):
+ return self.tokens[1:-1]
+
class Assignment(TokenList):
"""An assignment like 'var := val;'"""