]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Modernize deferred callable for many-to-one comparison
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Nov 2018 16:21:39 +0000 (11:21 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Nov 2018 01:55:57 +0000 (20:55 -0500)
commitd5c2db437e584af9f1224ce28e3cec3618b7d90e
tree84937c9980a87422ec03c21e802a9b6867b6f0db
parent1f13c8c833ebd96c09d1499b2504aa4950dca709
Modernize deferred callable for many-to-one comparison

Improved the behavior of a relationship-bound many-to-one object expression
such that the retrieval of column values on the related object are now
resilient against the object being detached from its parent
:class:`.Session`, even if the attribute has been expired.  New features
within the :class:`.InstanceState` are used to memoize the last known value
of a particular column attribute before its expired, so that the expression
can still evaluate when the object is detached and expired at the same
time.  Error conditions are also improved using modern attribute state
features to produce more specific messages as needed.

To support the value being mutated while also being resilient towards
expiration, a new feature to InstanceState is added ._last_known_values
which holds onto the expired value when an individual key is expired.
Only takes effect specific to keys and InstanceState objects that
received a special instruction so this does not add to overall
memory/latency.

Fixes: #4359
Change-Id: Iff272e667bf741074549db550bf65348553ca8e7
doc/build/changelog/migration_13.rst
doc/build/changelog/unreleased_13/4359.rst [new file with mode: 0644]
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/orm/state.py
test/orm/test_attributes.py
test/orm/test_naturalpks.py
test/orm/test_query.py
test/orm/test_session.py