MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _commit

Method _commit

lib/sqlalchemy/orm/state.py:967–994  ·  view source on GitHub ↗

Commit attributes. This is used by a partial-attribute load operation to mark committed those attributes which were refreshed from the database. Attributes marked as "expired" can potentially remain "expired" after this step if a value was not populated in state.dic

(self, dict_: _InstanceDict, keys: Iterable[str])

Source from the content-addressed store, hash-verified

965 )
966
967 def _commit(self, dict_: _InstanceDict, keys: Iterable[str]) -> None:
968 """Commit attributes.
969
970 This is used by a partial-attribute load operation to mark committed
971 those attributes which were refreshed from the database.
972
973 Attributes marked as "expired" can potentially remain "expired" after
974 this step if a value was not populated in state.dict.
975
976 """
977 for key in keys:
978 self.committed_state.pop(key, None)
979
980 self.expired = False
981
982 self.expired_attributes.difference_update(
983 set(keys).intersection(dict_)
984 )
985
986 # the per-keys commit removes object-level callables,
987 # while that of commit_all does not. it's not clear
988 # if this behavior has a clear rationale, however tests do
989 # ensure this is what it does.
990 if self.callables:
991 for key in (
992 set(self.callables).intersection(keys).intersection(dict_)
993 ):
994 del self.callables[key]
995
996 def _commit_all(
997 self,

Callers 7

_instanceFunction · 0.80
set_committed_valueMethod · 0.80
set_committed_valueMethod · 0.80
_commit_someattrMethod · 0.80

Calls 3

popMethod · 0.45
difference_updateMethod · 0.45
intersectionMethod · 0.45

Tested by 2

_commit_someattrMethod · 0.64