MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / clear_with_event

Method clear_with_event

lib/sqlalchemy/orm/collections.py:556–565  ·  view source on GitHub ↗

Empty the collection, firing a mutation event for each entity.

(
        self, initiator: Optional[AttributeEventToken] = None
    )

Source from the content-addressed store, hash-verified

554 self._data()._sa_remover(item, _sa_initiator=False)
555
556 def clear_with_event(
557 self, initiator: Optional[AttributeEventToken] = None
558 ) -> None:
559 """Empty the collection, firing a mutation event for each entity."""
560
561 if self.empty:
562 self._refuse_empty()
563 remover = self._data()._sa_remover
564 for item in list(self):
565 remover(item, _sa_initiator=initiator)
566
567 def clear_without_event(self) -> None:
568 """Empty the collection, firing no events."""

Callers 1

deleteMethod · 0.80

Calls 1

_refuse_emptyMethod · 0.95

Tested by

no test coverage detected