class documentation

class WriteOnlyCollection(AbstractCollectionWriter[_T]): (source)

View In Hierarchy

Write-only collection which can synchronize changes into the attribute event system. The :class:`.WriteOnlyCollection` is used in a mapping by using the ``"write_only"`` lazy loading strategy with :func:`_orm.relationship`. For background on this configuration, see :ref:`write_only_relationship`. .. versionadded:: 2.0 .. seealso:: :ref:`write_only_relationship`

Method __iter__ Undocumented
Method add Add an item to this :class:`_orm.WriteOnlyCollection`.
Method add_all Add an iterable of items to this :class:`_orm.WriteOnlyCollection`.
Method delete Produce a :class:`_dml.Delete` which will refer to rows in terms of this instance-local :class:`_orm.WriteOnlyCollection`.
Method insert For one-to-many collections, produce a :class:`_dml.Insert` which will insert new rows in terms of this this instance-local :class:`_orm.WriteOnlyCollection`.
Method remove Remove an item from this :class:`_orm.WriteOnlyCollection`.
Method select Produce a :class:`_sql.Select` construct that represents the rows within this instance-local :class:`_orm.WriteOnlyCollection`.
Method update Produce a :class:`_dml.Update` which will refer to rows in terms of this instance-local :class:`_orm.WriteOnlyCollection`.
Class Variable __slots__ Undocumented

Inherited from AbstractCollectionWriter:

Method __init__ Undocumented
Instance Variable attr Undocumented
Instance Variable instance Undocumented
Method _add_all_impl Undocumented
Method _remove_impl Undocumented
Instance Variable _from_obj Undocumented
Instance Variable _order_by_clauses Undocumented
Instance Variable _where_criteria Undocumented
def __iter__(self) -> NoReturn: (source)

Undocumented

def add(self, item: _T): (source)

Add an item to this :class:`_orm.WriteOnlyCollection`. The given item will be persisted to the database in terms of the parent instance's collection on the next flush.

def add_all(self, iterator: Iterable[_T]): (source)

Add an iterable of items to this :class:`_orm.WriteOnlyCollection`. The given items will be persisted to the database in terms of the parent instance's collection on the next flush.

def delete(self) -> Delete[_T]: (source)

Produce a :class:`_dml.Delete` which will refer to rows in terms of this instance-local :class:`_orm.WriteOnlyCollection`.

def insert(self) -> Insert[_T]: (source)

For one-to-many collections, produce a :class:`_dml.Insert` which will insert new rows in terms of this this instance-local :class:`_orm.WriteOnlyCollection`. This construct is only supported for a :class:`_orm.Relationship` that does **not** include the :paramref:`_orm.relationship.secondary` parameter. For relationships that refer to a many-to-many table, use ordinary bulk insert techniques to produce new objects, then use :meth:`_orm.AbstractCollectionWriter.add_all` to associate them with the collection.

def remove(self, item: _T): (source)

Remove an item from this :class:`_orm.WriteOnlyCollection`. The given item will be removed from the parent instance's collection on the next flush.

def select(self) -> Select[Tuple[_T]]: (source)

Produce a :class:`_sql.Select` construct that represents the rows within this instance-local :class:`_orm.WriteOnlyCollection`.

def update(self) -> Update[_T]: (source)

Produce a :class:`_dml.Update` which will refer to rows in terms of this instance-local :class:`_orm.WriteOnlyCollection`.