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

Class _ColumnMetrics

lib/sqlalchemy/sql/base.py:1466–1507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1464
1465
1466class _ColumnMetrics(Generic[_COL_co]):
1467 __slots__ = ("column",)
1468
1469 column: _COL_co
1470
1471 def __init__(
1472 self, collection: ColumnCollection[Any, _COL_co], col: _COL_co
1473 ) -> None:
1474 self.column = col
1475
1476 # proxy_index being non-empty means it was initialized.
1477 # so we need to update it
1478 pi = collection._proxy_index
1479 if pi:
1480 for eps_col in col._expanded_proxy_set:
1481 pi[eps_col].add(self)
1482
1483 def get_expanded_proxy_set(self) -> FrozenSet[ColumnElement[Any]]:
1484 return self.column._expanded_proxy_set
1485
1486 def dispose(self, collection: ColumnCollection[_COLKEY, _COL_co]) -> None:
1487 pi = collection._proxy_index
1488 if not pi:
1489 return
1490 for col in self.column._expanded_proxy_set:
1491 colset = pi.get(col, None)
1492 if colset:
1493 colset.discard(self)
1494 if colset is not None and not colset:
1495 del pi[col]
1496
1497 def embedded(
1498 self,
1499 target_set: Union[
1500 Set[ColumnElement[Any]], FrozenSet[ColumnElement[Any]]
1501 ],
1502 ) -> bool:
1503 expanded_proxy_set = self.column._expanded_proxy_set
1504 for t in target_set.difference(expanded_proxy_set):
1505 if not expanded_proxy_set.intersection(_expand_cloned([t])):
1506 return False
1507 return True
1508
1509
1510class ColumnCollection(Generic[_COLKEY, _COL_co]):

Callers 6

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

Calls

no outgoing calls

Tested by

no test coverage detected