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

Method _conditional_expire

lib/sqlalchemy/orm/session.py:3294–3303  ·  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

3292 self._conditional_expire(st_)
3293
3294 def _conditional_expire(
3295 self, state: InstanceState[Any], autoflush: Optional[bool] = None
3296 ) -> None:
3297 """Expire a state if persistent, else expunge if pending"""
3298
3299 if state.key:
3300 state._expire(state.dict, self.identity_map._modified)
3301 elif state in self._new:
3302 self._new.pop(state)
3303 state._detach(self)
3304
3305 def expunge(self, instance: object) -> None:
3306 """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