MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _remove_newly_deleted

Method _remove_newly_deleted

lib/sqlalchemy/orm/session.py:3536–3556  ·  view source on GitHub ↗
(
        self, states: Iterable[InstanceState[Any]]
    )

Source from the content-addressed store, hash-verified

3534 self._transaction._dirty[state] = True
3535
3536 def _remove_newly_deleted(
3537 self, states: Iterable[InstanceState[Any]]
3538 ) -> None:
3539 persistent_to_deleted = self.dispatch.persistent_to_deleted or None
3540 for state in states:
3541 if self._transaction:
3542 self._transaction._deleted[state] = True
3543
3544 if persistent_to_deleted is not None:
3545 # get a strong reference before we pop out of
3546 # self._deleted
3547 obj = state.obj() # noqa
3548
3549 self.identity_map.safe_discard(state)
3550 self._deleted.pop(state, None)
3551 state._deleted = True
3552 # can't call state._detach() here, because this state
3553 # is still in the transaction snapshot and needs to be
3554 # tracked as part of that
3555 if persistent_to_deleted is not None:
3556 persistent_to_deleted(self, state)
3557
3558 def add(self, instance: object, *, _warn: bool = True) -> None:
3559 """Place an object into this :class:`_orm.Session`.

Callers 5

get_from_identityFunction · 0.80
was_already_deletedMethod · 0.80

Calls 2

safe_discardMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected