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

Function group_functions

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

Source from the content-addressed store, hash-verified

378
379@recurse(sql.Function)
380def group_functions(tlist):
381 has_create = False
382 has_table = False
383 has_as = False
384 for tmp_token in tlist.tokens:
385 if tmp_token.value.upper() == 'CREATE':
386 has_create = True
387 if tmp_token.value.upper() == 'TABLE':
388 has_table = True
389 if tmp_token.value == 'AS':
390 has_as = True
391 if has_create and has_table and not has_as:
392 return
393
394 tidx, token = tlist.token_next_by(t=T.Name)
395 while token:
396 nidx, next_ = tlist.token_next(tidx)
397 if isinstance(next_, sql.Parenthesis):
398 over_idx, over = tlist.token_next(nidx)
399 if over and isinstance(over, sql.Over):
400 eidx = over_idx
401 else:
402 eidx = nidx
403 tlist.group_tokens(sql.Function, tidx, eidx)
404 tidx, token = tlist.token_next_by(t=T.Name, idx=tidx)
405
406
407@recurse(sql.Identifier)

Callers

nothing calls this directly

Calls 3

token_next_byMethod · 0.80
token_nextMethod · 0.80
group_tokensMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…