MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _setup_collections

Method _setup_collections

lib/sqlalchemy/sql/selectable.py:943–967  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

941 return self._columns.as_readonly() # type: ignore[return-value]
942
943 def _setup_collections(self) -> None:
944 with util.mini_gil:
945 # detect another thread that raced ahead
946 if "_columns" in self.__dict__:
947 assert "primary_key" in self.__dict__
948 assert "foreign_keys" in self.__dict__
949 return
950
951 _columns: WriteableColumnCollection[Any, Any] = (
952 WriteableColumnCollection()
953 )
954 primary_key = ColumnSet()
955 foreign_keys: Set[KeyedColumnElement[Any]] = set()
956
957 self._populate_column_collection(
958 columns=_columns,
959 primary_key=primary_key,
960 foreign_keys=foreign_keys,
961 )
962
963 # assigning these three collections separately is not itself
964 # atomic, but greatly reduces the surface for problems
965 self._columns = _columns
966 self.primary_key = primary_key # type: ignore
967 self.foreign_keys = foreign_keys # type: ignore
968
969 @util.ro_non_memoized_property
970 def entity_namespace(self) -> _EntityNamespace:

Callers 3

cMethod · 0.95
primary_keyMethod · 0.95
foreign_keysMethod · 0.95

Calls 3

ColumnSetClass · 0.85

Tested by

no test coverage detected