MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / presort_saves

Method presort_saves

lib/sqlalchemy/orm/dependency.py:1052–1084  ·  view source on GitHub ↗
(self, uowcommit, states)

Source from the content-addressed store, hash-verified

1050 )
1051
1052 def presort_saves(self, uowcommit, states):
1053 if not self.passive_updates:
1054 # if no passive updates, load history on
1055 # each collection where parent has changed PK,
1056 # so that prop_has_changes() returns True
1057 for state in states:
1058 if self._pks_changed(uowcommit, state):
1059 uowcommit.get_attribute_history(
1060 state, self.key, attributes.PASSIVE_OFF
1061 )
1062
1063 if not self.cascade.delete_orphan:
1064 return
1065
1066 # check for child items removed from the collection
1067 # if delete_orphan check is turned on.
1068 for state in states:
1069 history = uowcommit.get_attribute_history(
1070 state, self.key, attributes.PASSIVE_NO_INITIALIZE
1071 )
1072 if history:
1073 for child in history.deleted:
1074 if self.hasparent(child) is False:
1075 uowcommit.register_object(
1076 child,
1077 isdelete=True,
1078 operation="delete",
1079 prop=self.prop,
1080 )
1081 for c, m, st_, dct_ in self.mapper.cascade_iterator(
1082 "delete", child
1083 ):
1084 uowcommit.register_object(st_, isdelete=True)
1085
1086 def process_deletes(self, uowcommit, states):
1087 secondary_delete = []

Callers

nothing calls this directly

Calls 5

_pks_changedMethod · 0.95
get_attribute_historyMethod · 0.80
register_objectMethod · 0.80
hasparentMethod · 0.45
cascade_iteratorMethod · 0.45

Tested by

no test coverage detected