MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _expire_attributes

Method _expire_attributes

lib/sqlalchemy/orm/state.py:781–812  ·  view source on GitHub ↗
(
        self,
        dict_: _InstanceDict,
        attribute_names: Iterable[str],
        no_loader: bool = False,
    )

Source from the content-addressed store, hash-verified

779 self.manager.dispatch.expire(self, None)
780
781 def _expire_attributes(
782 self,
783 dict_: _InstanceDict,
784 attribute_names: Iterable[str],
785 no_loader: bool = False,
786 ) -> None:
787 pending = self.__dict__.get("_pending_mutations", None)
788
789 callables = self.callables
790
791 for key in attribute_names:
792 impl = self.manager[key].impl
793 if impl.accepts_scalar_loader:
794 if no_loader and (impl.callable_ or key in callables):
795 continue
796
797 self.expired_attributes.add(key)
798 if callables and key in callables:
799 del callables[key]
800 old = dict_.pop(key, NO_VALUE)
801 if is_collection_impl(impl) and old is not NO_VALUE:
802 impl._invalidate_collection(old)
803
804 lkv = self._last_known_values
805 if lkv is not None and key in lkv and old is not NO_VALUE:
806 lkv[key] = old
807
808 self.committed_state.pop(key, None)
809 if pending:
810 pending.pop(key, None)
811
812 self.manager.dispatch.expire(self, attribute_names)
813
814 def _load_expired(
815 self, state: InstanceState[_O], passive: PassiveFlag

Calls 6

is_collection_implFunction · 0.85
getMethod · 0.45
addMethod · 0.45
popMethod · 0.45
expireMethod · 0.45