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

Method process_saves

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected