MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _conditional_expire

Method _conditional_expire

lib/sqlalchemy/orm/session.py:3396–3405  ·  view source on GitHub ↗

Expire a state if persistent, else expunge if pending

(
        self, state: InstanceState[Any], autoflush: Optional[bool] = None
    )

Source from the content-addressed store, hash-verified

3394 self._conditional_expire(st_)
3395
3396 def _conditional_expire(
3397 self, state: InstanceState[Any], autoflush: Optional[bool] = None
3398 ) -> None:
3399 """Expire a state if persistent, else expunge if pending"""
3400
3401 if state.key:
3402 state._expire(state.dict, self.identity_map._modified)
3403 elif state in self._new:
3404 self._new.pop(state)
3405 state._detach(self)
3406
3407 def expunge(self, instance: object) -> None:
3408 """Remove the `instance` from this ``Session``.

Callers 1

_expire_stateMethod · 0.95

Calls 3

_expireMethod · 0.80
_detachMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected