MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / get_cte_from_token

Function get_cte_from_token

mssqlcli/packages/parseutils/ctes.py:96–112  ·  view source on GitHub ↗
(tok, pos0)

Source from the content-addressed store, hash-verified

94
95
96def get_cte_from_token(tok, pos0):
97 cte_name = tok.get_real_name()
98 if not cte_name:
99 return None
100
101 # Find the start position of the opening parens enclosing the cte body
102 idx, parens = tok.token_next_by(Parenthesis)
103 if not parens:
104 return None
105
106 start_pos = pos0 + token_start_pos(tok.tokens, idx)
107 cte_len = len(str(parens)) # includes parens
108 stop_pos = start_pos + cte_len
109
110 column_names = extract_column_names(parens)
111
112 return TableExpression(cte_name, column_names, start_pos, stop_pos)
113
114
115def extract_column_names(parsed):

Callers 1

extract_ctesFunction · 0.85

Calls 2

token_start_posFunction · 0.85
extract_column_namesFunction · 0.70

Tested by

no test coverage detected