diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-26 15:33:04 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-26 15:33:04 -0400 |
| commit | 5abb036e9b9eba0f61cf9617dea2d879c2d5b09c (patch) | |
| tree | c800de05cebaa5641a37f8bb1381fbfb58c34504 /lib/sqlalchemy/orm/state.py | |
| parent | ac1c19dee7d5ac784a7c913b1555f58d9cd4ec80 (diff) | |
| download | sqlalchemy-5abb036e9b9eba0f61cf9617dea2d879c2d5b09c.tar.gz | |
Don't expire "deferred" attributes in make_transient_to_detached
Fixed issue where the :func:`.make_transient_to_detached` function
would expire all attributes on the target object, including "deferred"
attributes, which has the effect of the attribute being undeferred
for the next refesh, causing an unexpected load of the attribute.
Change-Id: I82a385e3033e3f3c31569b1e908efb5f258d0f27
Fixes: #4084
Diffstat (limited to 'lib/sqlalchemy/orm/state.py')
| -rw-r--r-- | lib/sqlalchemy/orm/state.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 2e53fe9e3..4964c22e6 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -610,6 +610,7 @@ class InstanceState(interfaces.InspectionAttr): def unmodified_intersection(self, keys): """Return self.unmodified.intersection(keys).""" + return set(keys).intersection(self.manager).\ difference(self.committed_state) @@ -626,6 +627,18 @@ class InstanceState(interfaces.InspectionAttr): difference(self.dict) @property + def unloaded_expirable(self): + """Return the set of keys which do not have a loaded value. + + This includes expired attributes and any other attribute that + was never populated or modified. + + """ + return self.unloaded.intersection( + attr for attr in self.manager + if self.manager[attr].impl.expire_missing) + + @property def _unloaded_non_object(self): return self.unloaded.intersection( attr for attr in self.manager |
