@@ -15,12 +15,12 @@ class AlignedIndentFilter(object):
1515 join_words = (r'((LEFT\s+|RIGHT\s+|FULL\s+)?'
1616 r'(INNER\s+|OUTER\s+|STRAIGHT\s+)?|'
1717 r'(CROSS\s+|NATURAL\s+)?)?JOIN\b' )
18- by_words = ( ' GROUP BY' , ' ORDER BY' )
18+ by_words = r'( GROUP| ORDER)\s+BY\b'
1919 split_words = ('FROM' ,
20- join_words , 'ON' ,
20+ join_words , 'ON' , by_words ,
2121 'WHERE' , 'AND' , 'OR' ,
22- 'GROUP BY' , ' HAVING' , 'LIMIT' ,
23- 'ORDER BY' , ' UNION' , 'VALUES' ,
22+ 'HAVING' , 'LIMIT' ,
23+ 'UNION' , 'VALUES' ,
2424 'SET' , 'BETWEEN' , 'EXCEPT' )
2525
2626 def __init__ (self , char = ' ' , n = '\n ' ):
@@ -106,7 +106,7 @@ def _split_kwds(self, tlist):
106106 # word as aligner
107107 if (
108108 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 )
110110 ):
111111 token_indent = token .value .split ()[0 ]
112112 else :
@@ -123,7 +123,7 @@ def _process_default(self, tlist):
123123 pidx , prev_ = tlist .token_prev (idx )
124124 # HACK: make "group/order by" work. Longer than max_len.
125125 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 )
127127 ) else 0
128128 with offset (self , offset_ ):
129129 self ._process (sgroup )
0 commit comments