MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _ColumnMetrics

Class _ColumnMetrics

lib/sqlalchemy/sql/base.py:1733–1774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1731
1732
1733class _ColumnMetrics(Generic[_COL_co]):
1734 __slots__ = ("column",)
1735
1736 column: _COL_co
1737
1738 def __init__(
1739 self, collection: ColumnCollection[Any, _COL_co], col: _COL_co
1740 ) -> None:
1741 self.column = col
1742
1743 # proxy_index being non-empty means it was initialized.
1744 # so we need to update it
1745 pi = collection._proxy_index
1746 if pi:
1747 for eps_col in col._expanded_proxy_set:
1748 pi[eps_col].add(self)
1749
1750 def get_expanded_proxy_set(self) -> FrozenSet[ColumnElement[Any]]:
1751 return self.column._expanded_proxy_set
1752
1753 def dispose(self, collection: ColumnCollection[_COLKEY, _COL_co]) -> None:
1754 pi = collection._proxy_index
1755 if not pi:
1756 return
1757 for col in self.column._expanded_proxy_set:
1758 colset = pi.get(col, None)
1759 if colset:
1760 colset.discard(self)
1761 if colset is not None and not colset:
1762 del pi[col]
1763
1764 def embedded(
1765 self,
1766 target_set: Union[
1767 Set[ColumnElement[Any]], FrozenSet[ColumnElement[Any]]
1768 ],
1769 ) -> bool:
1770 expanded_proxy_set = self.column._expanded_proxy_set
1771 for t in target_set.difference(expanded_proxy_set):
1772 if not expanded_proxy_set.intersection(_expand_cloned([t])):
1773 return False
1774 return True
1775
1776
1777class ColumnCollection(Generic[_COLKEY, _COL_co]):

Callers 6

__setstate__Method · 0.85
addMethod · 0.85
_append_new_columnMethod · 0.85
replaceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected