MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _expunge_states

Method _expunge_states

lib/sqlalchemy/orm/session.py:3428–3443  ·  view source on GitHub ↗
(
        self, states: Iterable[InstanceState[Any]], to_transient: bool = False
    )

Source from the content-addressed store, hash-verified

3426 self._expunge_states([state] + [st_ for o, m, st_, dct_ in cascaded])
3427
3428 def _expunge_states(
3429 self, states: Iterable[InstanceState[Any]], to_transient: bool = False
3430 ) -> None:
3431 for state in states:
3432 if state in self._new:
3433 self._new.pop(state)
3434 elif self.identity_map.contains_state(state):
3435 self.identity_map.safe_discard(state)
3436 self._deleted.pop(state, None)
3437 elif self._transaction:
3438 # state is "detached" from being deleted, but still present
3439 # in the transaction snapshot
3440 self._transaction._deleted.pop(state, None)
3441 statelib.InstanceState._detach_states(
3442 states, self, to_transient=to_transient
3443 )
3444
3445 def _register_persistent(self, states: Set[InstanceState[Any]]) -> None:
3446 """Register all persistent objects from a flush.

Callers 6

expungeMethod · 0.95
_flushMethod · 0.95
_restore_snapshotMethod · 0.80
make_transientFunction · 0.80

Calls 4

_detach_statesMethod · 0.80
popMethod · 0.45
contains_stateMethod · 0.45
safe_discardMethod · 0.45