summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-02-20 12:15:57 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-02-20 16:41:48 -0500
commit66a246bd31730d53fb6b0e606d67ea4247f5e56c (patch)
tree3d690237e75b90334aa39cc95be66f3cb7ab4149 /lib/sqlalchemy/ext
parent5cb5b8b5f7a5b4488fb5df82c53861d565537405 (diff)
downloadsqlalchemy-66a246bd31730d53fb6b0e606d67ea4247f5e56c.tar.gz
Default to using current mapped class as owner if none found
Repaired regression caused in 1.2.3 and 1.1.16 regarding association proxy objects, revising the approach to :ticket:`4185` when calculating the "owning class" of an association proxy to default to choosing the current class if the proxy object is not directly associated with a mapped class, such as a mixin. Change-Id: I87d0ac09f695dc285bd4bbe0a547f1d5ce23e068 Fixes: #4185
Diffstat (limited to 'lib/sqlalchemy/ext')
-rw-r--r--lib/sqlalchemy/ext/associationproxy.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py
index 72200c5e2..1ebc7b420 100644
--- a/lib/sqlalchemy/ext/associationproxy.py
+++ b/lib/sqlalchemy/ext/associationproxy.py
@@ -271,7 +271,12 @@ class AssociationProxy(interfaces.InspectionAttrInfo):
# note we can get our real .key here too
owner = insp.mapper.class_manager._locate_owning_manager(self)
- self.owning_class = owner.class_
+ if owner is not None:
+ self.owning_class = owner.class_
+ else:
+ # the proxy is attached to a class that is not mapped
+ # (like a mixin), we are mapped, so, it's us.
+ self.owning_class = target_cls
def __get__(self, obj, class_):
if self.owning_class is None: