]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Propagate key for collection events
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 10 Aug 2022 14:53:11 +0000 (10:53 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Aug 2022 00:05:32 +0000 (20:05 -0400)
commit6cef8526226ab6033dfef1f793be87bff2160c04
tree693a5b244cbb6f02a78f9d1249e6bd58f90f8bfc
parenta134ec1760df6295d537ff63df7aee83d957bf6a
Propagate key for collection events

Added new parameter :paramref:`_orm.AttributeEvents.include_key`, which
will include the dictionary or list key for operations such as
``__setitem__()`` (e.g. ``obj[key] = value``) and ``__delitem__()`` (e.g.
``del obj[key]``), using a new keyword parameter "key" or "keys", depending
on event, e.g. :paramref:`_orm.AttributeEvents.append.key`,
:paramref:`_orm.AttributeEvents.bulk_replace.keys`. This allows event
handlers to take into account the key that was passed to the operation and
is of particular importance for dictionary operations working with
:class:`_orm.MappedCollection`.

Fixes: #8375
Change-Id: Icc472f7c28848f94e15c94a399cc13a88782e1e4
doc/build/changelog/unreleased_20/8375.rst [new file with mode: 0644]
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/orm/events.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/unitofwork.py
test/orm/test_attributes.py