summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-03-05 14:48:00 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-03-05 18:05:56 -0500
commit08a8e8cf3b06ed9eb4003f5727a3551d2b479509 (patch)
tree939bccce14e90daf0cce91bc3c16c9a80f8b09a9 /lib/sqlalchemy
parent0e146706058c8e4920c675644623601f2c4930d7 (diff)
downloadsqlalchemy-08a8e8cf3b06ed9eb4003f5727a3551d2b479509.tar.gz
Don't include AliasedClass when pickling options
Fixed 1.2 regression where a mapper option that contains an :class:`.AliasedClass` object, as is typical when using the :meth:`.QueryableAttribute.of_type` method, could not be pickled. 1.1's behavior was to omit the aliased class objects from the path, so this behavior is restored. Change-Id: I4b36a422b7c0e6a6da7ee3ba3ab282c13917a31f Fixes: #4209
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/strategy_options.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py
index de9a11c56..43f571146 100644
--- a/lib/sqlalchemy/orm/strategy_options.py
+++ b/lib/sqlalchemy/orm/strategy_options.py
@@ -439,7 +439,7 @@ class _UnboundLoad(Load):
def __getstate__(self):
d = self.__dict__.copy()
- d['path'] = self._serialize_path(self.path)
+ d['path'] = self._serialize_path(self.path, filter_aliased_class=True)
return d
def __setstate__(self, state):
@@ -454,7 +454,7 @@ class _UnboundLoad(Load):
cls, propkey, of_type = key
prop = getattr(cls, propkey)
if of_type:
- prop = prop.of_type(prop)
+ prop = prop.of_type(of_type)
ret.append(prop)
else:
ret.append(key)
@@ -520,19 +520,19 @@ class _UnboundLoad(Load):
return to_chop[i:]
- def _serialize_path(self, path, reject_aliased_class=False):
+ def _serialize_path(self, path, filter_aliased_class=False):
ret = []
for token in path:
if isinstance(token, QueryableAttribute):
- if reject_aliased_class and (
- (token._of_type and
- inspect(token._of_type).is_aliased_class)
- or
- inspect(token.parent).is_aliased_class
- ):
- return False
- ret.append(
- (token._parentmapper.class_, token.key, token._of_type))
+ if filter_aliased_class and token._of_type and \
+ inspect(token._of_type).is_aliased_class:
+ ret.append(
+ (token._parentmapper.class_,
+ token.key, None))
+ else:
+ ret.append(
+ (token._parentmapper.class_, token.key,
+ token._of_type))
elif isinstance(token, PropComparator):
ret.append((token._parentmapper.class_, token.key, None))
else: