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

Method _add_bind

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

Source from the content-addressed store, hash-verified

2614 statelib.InstanceState._detach_states(all_states, self)
2615
2616 def _add_bind(self, key: _SessionBindKey, bind: _SessionBind) -> None:
2617 try:
2618 insp = inspect(key)
2619 except sa_exc.NoInspectionAvailable as err:
2620 if not isinstance(key, type):
2621 raise sa_exc.ArgumentError(
2622 "Not an acceptable bind target: %s" % key
2623 ) from err
2624 else:
2625 self.__binds[key] = bind
2626 else:
2627 if TYPE_CHECKING:
2628 assert isinstance(insp, Inspectable)
2629
2630 if isinstance(insp, TableClause):
2631 self.__binds[insp] = bind
2632 elif insp_is_mapper(insp):
2633 self.__binds[insp.class_] = bind
2634 for _selectable in insp._all_tables:
2635 self.__binds[_selectable] = bind
2636 else:
2637 raise sa_exc.ArgumentError(
2638 "Not an acceptable bind target: %s" % key
2639 )
2640
2641 def bind_mapper(
2642 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