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

Function delete_obj

lib/sqlalchemy/orm/persistence.py:169–209  ·  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

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