@@ -15,12 +15,12 @@ class AlignedIndentFilter(object):
15
15
join_words = (r'((LEFT\s+|RIGHT\s+|FULL\s+)?'
16
16
r'(INNER\s+|OUTER\s+|STRAIGHT\s+)?|'
17
17
r'(CROSS\s+|NATURAL\s+)?)?JOIN\b' )
18
- by_words = ( ' GROUP BY' , ' ORDER BY' )
18
+ by_words = r'( GROUP| ORDER)\s+BY\b'
19
19
split_words = ('FROM' ,
20
- join_words , 'ON' ,
20
+ join_words , 'ON' , by_words ,
21
21
'WHERE' , 'AND' , 'OR' ,
22
- 'GROUP BY' , ' HAVING' , 'LIMIT' ,
23
- 'ORDER BY' , ' UNION' , 'VALUES' ,
22
+ 'HAVING' , 'LIMIT' ,
23
+ 'UNION' , 'VALUES' ,
24
24
'SET' , 'BETWEEN' , 'EXCEPT' )
25
25
26
26
def __init__ (self , char = ' ' , n = '\n ' ):
@@ -106,7 +106,7 @@ def _split_kwds(self, tlist):
106
106
# word as aligner
107
107
if (
108
108
token .match (T .Keyword , self .join_words , regex = True ) or
109
- token .match (T .Keyword , ( 'GROUP BY' , 'ORDER BY' ) )
109
+ token .match (T .Keyword , self . by_words , regex = True )
110
110
):
111
111
token_indent = token .value .split ()[0 ]
112
112
else :
@@ -123,7 +123,7 @@ def _process_default(self, tlist):
123
123
pidx , prev_ = tlist .token_prev (idx )
124
124
# HACK: make "group/order by" work. Longer than max_len.
125
125
offset_ = 3 if (
126
- prev_ and prev_ .match (T .Keyword , ( 'GROUP BY' , 'ORDER BY' ) )
126
+ prev_ and prev_ .match (T .Keyword , self . by_words , regex = True )
127
127
) else 0
128
128
with offset (self , offset_ ):
129
129
self ._process (sgroup )
0 commit comments