diff options
| author | John Bodley <john.bodley@airbnb.com> | 2019-01-15 15:46:28 -0800 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2019-03-10 08:59:16 +0100 |
| commit | 9aab1d2fc5c1ea9435bec404fa33b844996f2a4b (patch) | |
| tree | 39924feefc8efa4bd28735493e74527df0235dd0 /sqlparse | |
| parent | c4e9dae235abca0b4ae7099f9f9000c075b3a8e5 (diff) | |
| download | sqlparse-9aab1d2fc5c1ea9435bec404fa33b844996f2a4b.tar.gz | |
[tokenizer] Addressing @andialbrecht comments
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters/aligned_indent.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sqlparse/filters/aligned_indent.py b/sqlparse/filters/aligned_indent.py index 4b195bc..d3433c9 100644 --- a/sqlparse/filters/aligned_indent.py +++ b/sqlparse/filters/aligned_indent.py @@ -15,12 +15,12 @@ class AlignedIndentFilter(object): join_words = (r'((LEFT\s+|RIGHT\s+|FULL\s+)?' r'(INNER\s+|OUTER\s+|STRAIGHT\s+)?|' r'(CROSS\s+|NATURAL\s+)?)?JOIN\b') - by_words = ('GROUP BY', 'ORDER BY') + by_words = r'(GROUP|ORDER)\s+BY\b' split_words = ('FROM', - join_words, 'ON', + join_words, 'ON', by_words, 'WHERE', 'AND', 'OR', - 'GROUP BY', 'HAVING', 'LIMIT', - 'ORDER BY', 'UNION', 'VALUES', + 'HAVING', 'LIMIT', + 'UNION', 'VALUES', 'SET', 'BETWEEN', 'EXCEPT') def __init__(self, char=' ', n='\n'): @@ -106,7 +106,7 @@ class AlignedIndentFilter(object): # word as aligner if ( token.match(T.Keyword, self.join_words, regex=True) or - token.match(T.Keyword, ('GROUP BY', 'ORDER BY')) + token.match(T.Keyword, self.by_words, regex=True) ): token_indent = token.value.split()[0] else: @@ -123,7 +123,7 @@ class AlignedIndentFilter(object): pidx, prev_ = tlist.token_prev(idx) # HACK: make "group/order by" work. Longer than max_len. offset_ = 3 if ( - prev_ and prev_.match(T.Keyword, ('GROUP BY', 'ORDER BY')) + prev_ and prev_.match(T.Keyword, self.by_words, regex=True) ) else 0 with offset(self, offset_): self._process(sgroup) |
