Skip to content

Commit 1957755

Browse files
committed
clean up grouping
1 parent 00304af commit 1957755

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

sqlparse/engine/grouping.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ def _group_left_right(tlist, m, cls,
4242

4343
def _group_matching(tlist, cls):
4444
"""Groups Tokens that have beginning and end."""
45-
idx = 1 if imt(tlist, i=cls) else 0
45+
idx = 1 if isinstance(tlist, cls) else 0
4646

4747
token = tlist.token_next_by(m=cls.M_OPEN, idx=idx)
4848
while token:
4949
end = find_matching(tlist, token, cls.M_OPEN, cls.M_CLOSE)
5050
if end is not None:
51-
token = tlist.group_tokens(cls, tlist.tokens_between(token, end))
51+
tokens = tlist.tokens_between(token, end)
52+
token = tlist.group_tokens(cls, tokens)
5253
_group_matching(token, cls)
5354
token = tlist.token_next_by(m=cls.M_OPEN, idx=token)
5455

@@ -120,7 +121,7 @@ def group_period(tlist):
120121
def group_arrays(tlist):
121122
token = tlist.token_next_by(i=sql.SquareBrackets)
122123
while token:
123-
prev = tlist.token_prev(idx=token)
124+
prev = tlist.token_prev(token)
124125
if imt(prev, i=(sql.SquareBrackets, sql.Identifier, sql.Function),
125126
t=(T.Name, T.String.Symbol,)):
126127
tokens = tlist.tokens_between(prev, token)

0 commit comments

Comments
 (0)