diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-05-10 14:03:28 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-05-10 14:21:07 -0400 |
commit | c4f28097aa6a01efaa02b9792d5d15f33ae6baac (patch) | |
tree | 8b8ef70f2c07451ce36dd78dab23db5003b3db90 /lib | |
parent | 1ed19fc623f9dbfec33e6e81d93454fe025b63ed (diff) | |
download | sqlalchemy-c4f28097aa6a01efaa02b9792d5d15f33ae6baac.tar.gz |
Add conditionals specific to deferred for expire ro properties
Fixed bug where a :func:`.column_property` that is also marked as
"deferred" would be marked as "expired" during a flush, causing it
to be loaded along with the unexpiry of regular attributes even
though this attribute was never accessed.
Change-Id: Iaa9e17b66ece30a8e729e4af746b31ff99b1ec9a
Fixes: #3984
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/orm/persistence.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 5dc5a90b1..588a1d696 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -982,8 +982,16 @@ def _finalize_insert_update_commands(base_mapper, uowtransaction, states): if mapper._readonly_props: readonly = state.unmodified_intersection( - [p.key for p in mapper._readonly_props - if p.expire_on_flush or p.key not in state.dict] + [ + p.key for p in mapper._readonly_props + if ( + p.expire_on_flush and + (not p.deferred or p.key in state.dict) + ) or ( + not p.expire_on_flush and + not p.deferred and p.key not in state.dict + ) + ] ) if readonly: state._expire_attributes(state.dict, readonly) |