MCPcopy Index your code
hub / github.com/dbcli/pgcli / get_cte_from_token

Function get_cte_from_token

pgcli/packages/parseutils/ctes.py:97–113  ·  view source on GitHub ↗
(tok, pos0)

Source from the content-addressed store, hash-verified

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