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

Method process_deletes

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

Source from the content-addressed store, hash-verified

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