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

Method presort_saves

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

Source from the content-addressed store, hash-verified

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