MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / process_saves

Method process_saves

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

Source from the content-addressed store, hash-verified

1124 )
1125
1126 def process_saves(self, uowcommit, states):
1127 secondary_delete = []
1128 secondary_insert = []
1129 secondary_update = []
1130
1131 processed = self._get_reversed_processed_set(uowcommit)
1132 tmp = set()
1133
1134 for state in states:
1135 need_cascade_pks = not self.passive_updates and self._pks_changed(
1136 uowcommit, state
1137 )
1138 if need_cascade_pks:
1139 passive = (
1140 attributes.PASSIVE_OFF
1141 | attributes.INCLUDE_PENDING_MUTATIONS
1142 )
1143 else:
1144 passive = (
1145 attributes.PASSIVE_NO_INITIALIZE
1146 | attributes.INCLUDE_PENDING_MUTATIONS
1147 )
1148 history = uowcommit.get_attribute_history(state, self.key, passive)
1149 if history:
1150 for child in history.added:
1151 if processed is not None and (state, child) in processed:
1152 continue
1153 associationrow = {}
1154 if not self._synchronize(
1155 state, child, associationrow, False, uowcommit, "add"
1156 ):
1157 continue
1158 secondary_insert.append(associationrow)
1159 for child in history.deleted:
1160 if processed is not None and (state, child) in processed:
1161 continue
1162 associationrow = {}
1163 if not self._synchronize(
1164 state,
1165 child,
1166 associationrow,
1167 False,
1168 uowcommit,
1169 "delete",
1170 ):
1171 continue
1172 secondary_delete.append(associationrow)
1173
1174 tmp.update((c, state) for c in history.added + history.deleted)
1175
1176 if need_cascade_pks:
1177 for child in history.unchanged:
1178 associationrow = {}
1179 sync._update(
1180 state,
1181 self.parent,
1182 associationrow,
1183 "old_",

Callers

nothing calls this directly

Calls 8

_pks_changedMethod · 0.95
_synchronizeMethod · 0.95
_run_crudMethod · 0.95
get_attribute_historyMethod · 0.80
appendMethod · 0.45
updateMethod · 0.45
_updateMethod · 0.45

Tested by

no test coverage detected