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

Method _commit

lib/sqlalchemy/orm/state.py:962–989  ·  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

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

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