MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / expire_all

Method expire_all

lib/sqlalchemy/orm/session.py:3298–3331  ·  view source on GitHub ↗

Expires all persistent instances within this Session. When any attributes on a persistent instance is next accessed, a query will be issued using the :class:`.Session` object's current transactional context in order to load all expired attributes for the given instan

(self)

Source from the content-addressed store, hash-verified

3296 )
3297
3298 def expire_all(self) -> None:
3299 """Expires all persistent instances within this Session.
3300
3301 When any attributes on a persistent instance is next accessed,
3302 a query will be issued using the
3303 :class:`.Session` object's current transactional context in order to
3304 load all expired attributes for the given instance. Note that
3305 a highly isolated transaction will return the same values as were
3306 previously read in that same transaction, regardless of changes
3307 in database state outside of that transaction.
3308
3309 To expire individual objects and individual attributes
3310 on those objects, use :meth:`Session.expire`.
3311
3312 The :class:`.Session` object's default behavior is to
3313 expire all state whenever the :meth:`Session.rollback`
3314 or :meth:`Session.commit` methods are called, so that new
3315 state can be loaded for the new transaction. For this reason,
3316 calling :meth:`Session.expire_all` is not usually needed,
3317 assuming the transaction is isolated.
3318
3319 .. seealso::
3320
3321 :ref:`session_expire` - introductory material
3322
3323 :meth:`.Session.expire`
3324
3325 :meth:`.Session.refresh`
3326
3327 :meth:`_orm.Query.populate_existing`
3328
3329 """
3330 for state in self.identity_map.all_states():
3331 state._expire(state.dict, self.identity_map._modified)
3332
3333 def expire(
3334 self, instance: object, attribute_names: Optional[Iterable[str]] = None

Calls 2

_expireMethod · 0.80
all_statesMethod · 0.45