MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / process_saves

Method process_saves

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

Source from the content-addressed store, hash-verified

580 # if the old parent wasn't deleted but child was moved.
581
582 def process_saves(self, uowcommit, states):
583 should_null_fks = (
584 not self.cascade.delete_orphan
585 and not self.passive_deletes == "all"
586 )
587
588 for state in states:
589 history = uowcommit.get_attribute_history(
590 state, self.key, attributes.PASSIVE_NO_INITIALIZE
591 )
592 if history:
593 for child in history.added:
594 self._synchronize(
595 state, child, None, False, uowcommit, False
596 )
597 if child is not None and self.post_update:
598 self._post_update(child, uowcommit, [state])
599
600 for child in history.deleted:
601 if (
602 should_null_fks
603 and not self.cascade.delete_orphan
604 and not self.hasparent(child)
605 ):
606 self._synchronize(
607 state, child, None, True, uowcommit, False
608 )
609
610 if self._pks_changed(uowcommit, state):
611 for child in history.unchanged:
612 self._synchronize(
613 state, child, None, False, uowcommit, True
614 )
615
616 def _synchronize(
617 self, state, child, associationrow, clearkeys, uowcommit, pks_changed

Callers 2

executeMethod · 0.45
execute_aggregateMethod · 0.45

Calls 5

_synchronizeMethod · 0.95
_pks_changedMethod · 0.95
get_attribute_historyMethod · 0.80
_post_updateMethod · 0.80
hasparentMethod · 0.45

Tested by

no test coverage detected