]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add bulk_replace event, integrate with @validates
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 25 Jan 2017 16:51:04 +0000 (11:51 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 16 Mar 2017 21:16:49 +0000 (17:16 -0400)
commit9974e9a46bdf6c570c650aa911b76c2dcfd9327b
tree5631c6d247855cb8572d6c634987f23e6c068e0d
parent63a7b2d2d9402b06f9bc7745eed2d98ae9f8b11c
Add bulk_replace event, integrate with @validates

Added new attribute event :meth:`.AttributeEvents.bulk_replace`.
This event is triggered when a collection is assigned to a
relationship, before the incoming collection is compared with the
existing one.  This early event allows for conversion of incoming
non-ORM objects as well.  The event is integrated with the
``@validates`` decorator.

The ``@validates`` decorator now allows the decorated method to receive
objects from a "bulk collection set" operation that have not yet
been compared to the existing collection.  This allows incoming values
to be converted to compatible ORM objects as is already allowed
from an "append" event.   Note that this means that the
``@validates`` method is called for **all** values during a collection
assignment, rather than just the ones that are new.

Change-Id: I27f59db008d9e521d31a3e30143d7cd997e4b7b3
Fixes: #3896
doc/build/changelog/changelog_12.rst
doc/build/changelog/migration_12.rst
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/orm/events.py
lib/sqlalchemy/orm/util.py
test/orm/test_validators.py