MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / process_deletes

Method process_deletes

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

Source from the content-addressed store, hash-verified

536 )
537
538 def process_deletes(self, uowcommit, states):
539 # head object is being deleted, and we manage its list of
540 # child objects the child objects have to have their foreign
541 # key to the parent set to NULL this phase can be called
542 # safely for any cascade but is unnecessary if delete cascade
543 # is on.
544
545 if self.post_update or not self.passive_deletes == "all":
546 children_added = uowcommit.memo(("children_added", self), set)
547
548 for state in states:
549 history = uowcommit.get_attribute_history(
550 state, self.key, self._passive_delete_flag
551 )
552 if history:
553 for child in history.deleted:
554 if (
555 child is not None
556 and self.hasparent(child) is False
557 ):
558 self._synchronize(
559 state, child, None, True, uowcommit, False
560 )
561 if self.post_update and child:
562 self._post_update(child, uowcommit, [state])
563
564 if self.post_update or not self.cascade.delete:
565 for child in set(history.unchanged).difference(
566 children_added
567 ):
568 if child is not None:
569 self._synchronize(
570 state, child, None, True, uowcommit, False
571 )
572 if self.post_update and child:
573 self._post_update(
574 child, uowcommit, [state]
575 )
576
577 # technically, we can even remove each child from the
578 # collection here too. but this would be a somewhat
579 # inconsistent behavior since it wouldn't happen
580 # if the old parent wasn't deleted but child was moved.
581
582 def process_saves(self, uowcommit, states):
583 should_null_fks = (

Callers 2

executeMethod · 0.45
execute_aggregateMethod · 0.45

Calls 6

_synchronizeMethod · 0.95
get_attribute_historyMethod · 0.80
_post_updateMethod · 0.80
memoMethod · 0.45
hasparentMethod · 0.45
differenceMethod · 0.45

Tested by

no test coverage detected