diff options
| author | Diana Clarke <diana.joan.clarke@gmail.com> | 2016-04-05 18:58:21 -0400 |
|---|---|---|
| committer | Diana Clarke <diana.joan.clarke@gmail.com> | 2016-04-05 18:58:21 -0400 |
| commit | 0f502fa418e32177ae139afb7a816ff849baeef5 (patch) | |
| tree | 86b8976d11669f94828631a67d5f565cac765a8f /lib | |
| parent | fdb6ab6a1d5d55d900c388e039835c6433032977 (diff) | |
| download | sqlalchemy-pr/256.tar.gz | |
- don't load deferred columns on unexpire for merge with load=False,pr/256
fixes #3488
Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/properties.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/state.py | 12 |
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index 8197e041f..f3dce7541 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -218,7 +218,8 @@ class ColumnProperty(StrategizedProperty): impl = dest_state.get_impl(self.key) impl.set(dest_state, dest_dict, value, None) elif dest_state.has_identity and self.key not in dest_dict: - dest_state._expire_attributes(dest_dict, [self.key]) + dest_state._expire_attributes( + dest_dict, [self.key], no_loader=True) class Comparator(util.MemoizedSlots, PropComparator): """Produce boolean, comparison, and other operators for diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index dc5de7ac6..1cf1bdb24 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -1842,6 +1842,13 @@ class Session(_SessionClassMethods): merged_state.load_path = state.load_path merged_state.load_options = state.load_options + # since we are copying load_options, we need to copy + # the callables_ that would have been generated by those + # load_options. + # assumes that the callables we put in state.callables_ + # are not instance-specific (which they should not be) + merged_state._copy_callables(state) + for prop in mapper.iterate_properties: prop.merge(self, state, state_dict, merged_state, merged_dict, diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 1ad09ee83..2704367f9 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -485,6 +485,10 @@ class InstanceState(interfaces.InspectionAttr): if self.callables: self.callables.pop(key, None) + def _copy_callables(self, from_): + if 'callables' in from_.__dict__: + self.callables = dict(from_.callables) + @classmethod def _instance_level_callable_processor(cls, manager, fn, key): impl = manager[key].impl @@ -537,7 +541,7 @@ class InstanceState(interfaces.InspectionAttr): self.manager.dispatch.expire(self, None) - def _expire_attributes(self, dict_, attribute_names): + def _expire_attributes(self, dict_, attribute_names, no_loader=False): pending = self.__dict__.get('_pending_mutations', None) callables = self.callables @@ -545,6 +549,12 @@ class InstanceState(interfaces.InspectionAttr): for key in attribute_names: impl = self.manager[key].impl if impl.accepts_scalar_loader: + if no_loader and ( + impl.callable_ or + key in callables + ): + continue + self.expired_attributes.add(key) if callables and key in callables: del callables[key] |
