MCPcopy
hub / github.com/andialbrecht/sqlparse / group_period

Function group_period

sqlparse/engine/grouping.py:164–191  ·  view source on GitHub ↗
(tlist)

Source from the content-addressed store, hash-verified

162
163
164def group_period(tlist):
165 def match(token):
166 for ttype, value in ((T.Punctuation, '.'),
167 (T.Operator, '->'),
168 (T.Operator, '->>')):
169 if token.match(ttype, value):
170 return True
171 return False
172
173 def valid_prev(token):
174 sqlcls = sql.SquareBrackets, sql.Identifier
175 ttypes = T.Name, T.String.Symbol
176 return imt(token, i=sqlcls, t=ttypes)
177
178 def valid_next(token):
179 # issue261, allow invalid next token
180 return True
181
182 def post(tlist, pidx, tidx, nidx):
183 # next_ validation is being performed here. issue261
184 sqlcls = sql.SquareBrackets, sql.Function
185 ttypes = T.Name, T.String.Symbol, T.Wildcard, T.String.Single
186 next_ = tlist[nidx] if nidx is not None else None
187 valid_next = imt(next_, i=sqlcls, t=ttypes)
188
189 return (pidx, nidx) if valid_next else (pidx, tidx)
190
191 _group(tlist, sql.Identifier, match, valid_prev, valid_next, post)
192
193
194def group_as(tlist):

Callers

nothing calls this directly

Calls 1

_groupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…