diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2010-11-21 19:23:12 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2010-11-21 19:23:12 +0100 |
| commit | e3a64164683e34a597153005386f9ee53396c6a5 (patch) | |
| tree | f65b858b5d54b3b584985713f5adc265ced33fc1 /sqlparse | |
| parent | 08688ee4fc78fea0a6769cfa8738438c0eb8256d (diff) | |
| download | sqlparse-e3a64164683e34a597153005386f9ee53396c6a5.tar.gz | |
Ignore AND after BETWEEN when reindenting statements (fixes issue14).
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/filters.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sqlparse/filters.py b/sqlparse/filters.py index 2015674..a3ae192 100644 --- a/sqlparse/filters.py +++ b/sqlparse/filters.py @@ -133,10 +133,18 @@ class ReindentFilter(Filter): def _split_kwds(self, tlist): split_words = ('FROM', 'JOIN$', 'AND', 'OR', 'GROUP', 'ORDER', 'UNION', 'VALUES', - 'SET') - idx = 0 - token = tlist.token_next_match(idx, T.Keyword, split_words, + 'SET', 'BETWEEN') + def _next_token(i): + t = tlist.token_next_match(i, T.Keyword, split_words, regex=True) + if t and t.value.upper() == 'BETWEEN': + t = _next_token(tlist.token_index(t)+1) + if t and t.value.upper() == 'AND': + t = _next_token(tlist.token_index(t)+1) + return t + + idx = 0 + token = _next_token(idx) while token: prev = tlist.token_prev(tlist.token_index(token), False) offset = 1 @@ -151,8 +159,7 @@ class ReindentFilter(Filter): else: nl = self.nl() tlist.insert_before(token, nl) - token = tlist.token_next_match(tlist.token_index(nl) + offset, - T.Keyword, split_words, regex=True) + token = _next_token(tlist.token_index(nl) + offset) def _split_statements(self, tlist): idx = 0 |
