MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _init_cte_state

Method _init_cte_state

lib/sqlalchemy/sql/compiler.py:1615–1636  ·  view source on GitHub ↗

Initialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise.

(self)

Source from the content-addressed store, hash-verified

1613
1614 @util.memoized_instancemethod
1615 def _init_cte_state(self) -> MutableMapping[CTE, str]:
1616 """Initialize collections related to CTEs only if
1617 a CTE is located, to save on the overhead of
1618 these collections otherwise.
1619
1620 """
1621 # collect CTEs to tack on top of a SELECT
1622 # To store the query to print - Dict[cte, text_query]
1623 ctes: MutableMapping[CTE, str] = util.OrderedDict()
1624 self.ctes = ctes
1625
1626 # Detect same CTE references - Dict[(level, name), cte]
1627 # Level is required for supporting nesting
1628 self.ctes_by_level_name = {}
1629
1630 # To retrieve key/level in ctes_by_level_name -
1631 # Dict[cte_reference, (level, cte_name, cte_opts)]
1632 self.level_name_by_cte = {}
1633
1634 self.ctes_recursive = False
1635
1636 return ctes
1637
1638 @contextlib.contextmanager
1639 def _nested_result(self):

Callers 1

visit_cteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected