MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _add_bind

Method _add_bind

lib/sqlalchemy/orm/session.py:2710–2733  ·  view source on GitHub ↗
(self, key: _SessionBindKey, bind: _SessionBind)

Source from the content-addressed store, hash-verified

2708 statelib.InstanceState._detach_states(all_states, self)
2709
2710 def _add_bind(self, key: _SessionBindKey, bind: _SessionBind) -> None:
2711 try:
2712 insp = inspect(key)
2713 except sa_exc.NoInspectionAvailable as err:
2714 if not isinstance(key, type):
2715 raise sa_exc.ArgumentError(
2716 "Not an acceptable bind target: %s" % key
2717 ) from err
2718 else:
2719 self.__binds[key] = bind
2720 else:
2721 if TYPE_CHECKING:
2722 assert isinstance(insp, Inspectable)
2723
2724 if isinstance(insp, TableClause):
2725 self.__binds[insp] = bind
2726 elif insp_is_mapper(insp):
2727 self.__binds[insp.class_] = bind
2728 for _selectable in insp._all_tables:
2729 self.__binds[_selectable] = bind
2730 else:
2731 raise sa_exc.ArgumentError(
2732 "Not an acceptable bind target: %s" % key
2733 )
2734
2735 def bind_mapper(
2736 self, mapper: _EntityBindKey[_O], bind: _SessionBind

Callers 3

__init__Method · 0.95
bind_mapperMethod · 0.95
bind_tableMethod · 0.95

Calls 2

inspectFunction · 0.90
insp_is_mapperFunction · 0.85

Tested by

no test coverage detected