summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/engine/grouping.py2
-rw-r--r--sqlparse/filters.py13
2 files changed, 13 insertions, 2 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index ee534e3..a048128 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -301,7 +301,7 @@ def group_where(tlist):
if not isinstance(sgroup, sql.Where)]
idx = 0
token = tlist.token_next_match(idx, T.Keyword, 'WHERE')
- stopwords = ('ORDER', 'GROUP', 'LIMIT', 'UNION', 'EXCEPT')
+ stopwords = ('ORDER', 'GROUP', 'LIMIT', 'UNION', 'EXCEPT', 'HAVING')
while token:
tidx = tlist.token_index(token)
end = tlist.token_next_match(tidx + 1, T.Keyword, stopwords)
diff --git a/sqlparse/filters.py b/sqlparse/filters.py
index e576a26..47972e4 100644
--- a/sqlparse/filters.py
+++ b/sqlparse/filters.py
@@ -316,7 +316,7 @@ class ReindentFilter:
def _split_kwds(self, tlist):
split_words = ('FROM', 'STRAIGHT_JOIN$', 'JOIN$', 'AND', 'OR',
'GROUP', 'ORDER', 'UNION', 'VALUES',
- 'SET', 'BETWEEN', 'EXCEPT')
+ 'SET', 'BETWEEN', 'EXCEPT', 'HAVING')
def _next_token(i):
t = tlist.token_next_match(i, T.Keyword, split_words,
@@ -374,6 +374,17 @@ class ReindentFilter:
self._process_default(tlist)
self.indent -= 1
+ def _process_having(self, tlist):
+ token = tlist.token_next_match(0, T.Keyword, 'HAVING')
+ try:
+ tlist.insert_before(token, self.nl())
+ except ValueError: # issue121, errors in statement
+ pass
+ self.indent += 1
+ self._process_default(tlist)
+ self.indent -= 1
+
+
def _process_parenthesis(self, tlist):
first = tlist.token_next(0)
indented = False