MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __contains__

Method __contains__

lib/sqlalchemy/orm/session.py:4454–4465  ·  view source on GitHub ↗

Return True if the instance is associated with this session. The instance may be pending or persistent within the Session for a result of True.

(self, instance: object)

Source from the content-addressed store, hash-verified

4452 self.dispatch.transient_to_pending(self, state)
4453
4454 def __contains__(self, instance: object) -> bool:
4455 """Return True if the instance is associated with this session.
4456
4457 The instance may be pending or persistent within the Session for a
4458 result of True.
4459
4460 """
4461 try:
4462 state = attributes.instance_state(instance)
4463 except exc.NO_STATE as err:
4464 raise exc.UnmappedInstanceError(instance) from err
4465 return self._contains_state(state)
4466
4467 def __iter__(self) -> Iterator[object]:
4468 """Iterate over all pending or persistent instances within this

Callers

nothing calls this directly

Calls 1

_contains_stateMethod · 0.95

Tested by

no test coverage detected