MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _delete_obj

Function _delete_obj

lib/sqlalchemy/orm/persistence.py:167–207  ·  view source on GitHub ↗

Issue ``DELETE`` statements for a list of objects. This is called within the context of a UOWTransaction during a flush operation.

(base_mapper, states, uowtransaction)

Source from the content-addressed store, hash-verified

165
166
167def _delete_obj(base_mapper, states, uowtransaction):
168 """Issue ``DELETE`` statements for a list of objects.
169
170 This is called within the context of a UOWTransaction during a
171 flush operation.
172
173 """
174
175 states_to_delete = list(
176 _organize_states_for_delete(base_mapper, states, uowtransaction)
177 )
178
179 table_to_mapper = base_mapper._sorted_tables
180
181 for table in reversed(list(table_to_mapper.keys())):
182 mapper = table_to_mapper[table]
183 if table not in mapper._pks_by_table:
184 continue
185 elif mapper.inherits and mapper.passive_deletes:
186 continue
187
188 delete = _collect_delete_commands(
189 base_mapper, uowtransaction, table, states_to_delete
190 )
191
192 _emit_delete_statements(
193 base_mapper,
194 uowtransaction,
195 mapper,
196 table,
197 delete,
198 )
199
200 for (
201 state,
202 state_dict,
203 mapper,
204 connection,
205 update_version_id,
206 ) in states_to_delete:
207 mapper.dispatch.after_delete(mapper, connection, state)
208
209
210def _organize_states_for_save(base_mapper, states, uowtransaction):

Callers

nothing calls this directly

Calls 5

_collect_delete_commandsFunction · 0.85
_emit_delete_statementsFunction · 0.85
after_deleteMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected