summaryrefslogtreecommitdiff
path: root/sqlparse/engine
diff options
context:
space:
mode:
authorVictor Uriarte <victor.m.uriarte@intel.com>2016-06-14 04:15:27 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-15 13:29:17 -0700
commit56b28dc15023d36bab8764bea6df75e28651646e (patch)
tree9811b4a0624f092dc7cb886e1aaeec4354b272c0 /sqlparse/engine
parent5002bfa36c4fa2ee72eff18648b6ddc616b718f0 (diff)
downloadsqlparse-56b28dc15023d36bab8764bea6df75e28651646e.tar.gz
Make use of token_index more obvious
Diffstat (limited to 'sqlparse/engine')
-rw-r--r--sqlparse/engine/grouping.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py
index e7072d0..c52a759 100644
--- a/sqlparse/engine/grouping.py
+++ b/sqlparse/engine/grouping.py
@@ -64,7 +64,9 @@ def _group_matching(tlist, cls):
# this indicates invalid sql and unbalanced tokens.
# instead of break, continue in case other "valid" groups exist
continue
- tlist.group_tokens(cls, open_token, token)
+ oidx = tlist.token_index(open_token)
+ cidx = tlist.token_index(token)
+ tlist.group_tokens(cls, oidx, cidx)
def group_if(tlist):
@@ -196,10 +198,9 @@ def group_parenthesis(tlist):
def group_comments(tlist):
tidx, token = tlist.token_next_by(t=T.Comment)
while token:
- end = tlist.token_not_matching(
+ eidx, end = tlist.token_not_matching(
lambda tk: imt(tk, t=T.Comment) or tk.is_whitespace(), idx=tidx)
if end is not None:
- eidx = tlist.token_index(end)
eidx, end = tlist.token_prev(eidx, skip_ws=False)
tlist.group_tokens(sql.Comment, tidx, eidx)
@@ -218,7 +219,8 @@ def group_where(tlist):
end = tlist.tokens[eidx - 1]
# TODO: convert this to eidx instead of end token.
# i think above values are len(tlist) and eidx-1
- tlist.group_tokens(sql.Where, tidx, end)
+ eidx = tlist.token_index(end)
+ tlist.group_tokens(sql.Where, tidx, eidx)
tidx, token = tlist.token_next_by(m=sql.Where.M_OPEN, idx=tidx)