MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / ReadOnlyColumnCollection

Class ReadOnlyColumnCollection

lib/sqlalchemy/sql/base.py:2524–2564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2522
2523
2524class ReadOnlyColumnCollection(
2525 util.ReadOnlyContainer, ColumnCollection[_COLKEY, _COL_co]
2526):
2527 __slots__ = ("_parent",)
2528
2529 _parent: WriteableColumnCollection[_COLKEY, _COL_co]
2530
2531 def __init__(
2532 self, collection: WriteableColumnCollection[_COLKEY, _COL_co]
2533 ):
2534 object.__setattr__(self, "_parent", collection)
2535 object.__setattr__(self, "_index", collection._index)
2536 object.__setattr__(self, "_collection", collection._collection)
2537 object.__setattr__(self, "_colset", collection._colset)
2538 object.__setattr__(self, "_proxy_index", collection._proxy_index)
2539
2540 def _as_readonly(self) -> ReadOnlyColumnCollection[_COLKEY, _COL_co]:
2541 return self
2542
2543 def __getstate__(self) -> Dict[str, ColumnCollection[_COLKEY, _COL_co]]:
2544 return {"_parent": self._parent}
2545
2546 def __setstate__(self, state: Dict[str, Any]) -> None:
2547 parent = state["_parent"]
2548 self.__init__(parent) # type: ignore
2549
2550 def corresponding_column(
2551 self, column: _COL, require_embedded: bool = False
2552 ) -> Optional[Union[_COL, _COL_co]]:
2553 """Given a :class:`_expression.ColumnElement`, return the exported
2554 :class:`_expression.ColumnElement` object from this
2555 :class:`_expression.ColumnCollection`
2556 which corresponds to that original :class:`_expression.ColumnElement`
2557 via a common
2558 ancestor column.
2559
2560 See :meth:`.ColumnCollection.corresponding_column` for parameter
2561 information.
2562
2563 """
2564 return self._parent.corresponding_column(column, require_embedded)
2565
2566
2567class ColumnSet(util.OrderedSet["ColumnClause[Any]"]):

Callers 1

_as_readonlyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected