MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _DeleteState

Class _DeleteState

lib/sqlalchemy/orm/unitofwork.py:771–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769
770
771class _DeleteState(_PostSortRec):
772 __slots__ = "state", "mapper", "sort_key"
773
774 def __init__(self, uow, state):
775 self.state = state
776 self.mapper = state.mapper.base_mapper
777 self.sort_key = ("DeleteState", self.mapper._sort_key)
778
779 @util.preload_module("sqlalchemy.orm.persistence")
780 def execute_aggregate(self, uow, recs):
781 persistence = util.preloaded.orm_persistence
782 cls_ = self.__class__
783 mapper = self.mapper
784 our_recs = [
785 r for r in recs if r.__class__ is cls_ and r.mapper is mapper
786 ]
787 recs.difference_update(our_recs)
788 states = [self.state] + [r.state for r in our_recs]
789 persistence._delete_obj(
790 mapper, [s for s in states if uow.states[s][0]], uow
791 )
792
793 def __repr__(self):
794 return "%s(%s)" % (
795 self.__class__.__name__,
796 orm_util.state_str(self.state),
797 )

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected