From b3700f44ff6945d1ace9d5d809dd272c9acd268e Mon Sep 17 00:00:00 2001 From: Victor Uriarte Date: Sun, 19 Jun 2016 07:50:50 -0700 Subject: Previous fix for period failed when another token (non-groupable) followed. --- sqlparse/engine/grouping.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sqlparse/engine') diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 62357d3..42305c3 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -97,12 +97,17 @@ def group_period(tlist): return imt(token, i=sqlcls, t=ttypes) def valid_next(token): + # issue261, allow invalid next token + return True + + def post(tlist, pidx, tidx, nidx): + # next_ validation is being performed here. issue261 sqlcls = sql.SquareBrackets, sql.Function ttypes = T.Name, T.String.Symbol, T.Wildcard - return token is None or imt(token, i=sqlcls, t=ttypes) + next_ = tlist[nidx] if nidx is not None else None + valid_next = imt(next_, i=sqlcls, t=ttypes) - def post(tlist, pidx, tidx, nidx): - return (pidx, nidx) if nidx is not None else (pidx, tidx) + return (pidx, nidx) if valid_next else (pidx, tidx) _group(tlist, sql.Identifier, match, valid_prev, valid_next, post) -- cgit v1.2.1