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

Method _setup_collections

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

Source from the content-addressed store, hash-verified

912 return self._columns.as_readonly()
913
914 def _setup_collections(self) -> None:
915 with util.mini_gil:
916 # detect another thread that raced ahead
917 if "_columns" in self.__dict__:
918 assert "primary_key" in self.__dict__
919 assert "foreign_keys" in self.__dict__
920 return
921
922 _columns: ColumnCollection[Any, Any] = ColumnCollection()
923 primary_key = ColumnSet()
924 foreign_keys: Set[KeyedColumnElement[Any]] = set()
925
926 self._populate_column_collection(
927 columns=_columns,
928 primary_key=primary_key,
929 foreign_keys=foreign_keys,
930 )
931
932 # assigning these three collections separately is not itself
933 # atomic, but greatly reduces the surface for problems
934 self._columns = _columns
935 self.primary_key = primary_key # type: ignore
936 self.foreign_keys = foreign_keys # type: ignore
937
938 @util.ro_non_memoized_property
939 def entity_namespace(self) -> _EntityNamespace:

Callers 3

cMethod · 0.95
primary_keyMethod · 0.95
foreign_keysMethod · 0.95

Calls 3

ColumnCollectionClass · 0.85
ColumnSetClass · 0.85

Tested by

no test coverage detected