(self, uowcommit, states)
| 464 | ) |
| 465 | |
| 466 | def presort_saves(self, uowcommit, states): |
| 467 | children_added = uowcommit.memo(("children_added", self), set) |
| 468 | |
| 469 | should_null_fks = ( |
| 470 | not self.cascade.delete_orphan |
| 471 | and not self.passive_deletes == "all" |
| 472 | ) |
| 473 | |
| 474 | for state in states: |
| 475 | pks_changed = self._pks_changed(uowcommit, state) |
| 476 | |
| 477 | if not pks_changed or self.passive_updates: |
| 478 | passive = ( |
| 479 | attributes.PASSIVE_NO_INITIALIZE |
| 480 | | attributes.INCLUDE_PENDING_MUTATIONS |
| 481 | ) |
| 482 | else: |
| 483 | passive = ( |
| 484 | attributes.PASSIVE_OFF |
| 485 | | attributes.INCLUDE_PENDING_MUTATIONS |
| 486 | ) |
| 487 | |
| 488 | history = uowcommit.get_attribute_history(state, self.key, passive) |
| 489 | if history: |
| 490 | for child in history.added: |
| 491 | if child is not None: |
| 492 | uowcommit.register_object( |
| 493 | child, |
| 494 | cancel_delete=True, |
| 495 | operation="add", |
| 496 | prop=self.prop, |
| 497 | ) |
| 498 | |
| 499 | children_added.update(history.added) |
| 500 | |
| 501 | for child in history.deleted: |
| 502 | if not self.cascade.delete_orphan: |
| 503 | if should_null_fks: |
| 504 | uowcommit.register_object( |
| 505 | child, |
| 506 | isdelete=False, |
| 507 | operation="delete", |
| 508 | prop=self.prop, |
| 509 | ) |
| 510 | elif self.hasparent(child) is False: |
| 511 | uowcommit.register_object( |
| 512 | child, |
| 513 | isdelete=True, |
| 514 | operation="delete", |
| 515 | prop=self.prop, |
| 516 | ) |
| 517 | for c, m, st_, dct_ in self.mapper.cascade_iterator( |
| 518 | "delete", child |
| 519 | ): |
| 520 | uowcommit.register_object(st_, isdelete=True) |
| 521 | |
| 522 | if pks_changed: |
| 523 | if history: |
no test coverage detected