diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2018-02-20 17:52:11 -0500 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci.zzzcomputing.com> | 2018-02-20 17:52:11 -0500 |
| commit | 14eae5108d655e71bb80572109b4cd8f8a0fe51c (patch) | |
| tree | 30c81549ddf3f9509159c1b13f72ad590f9a791c /lib/sqlalchemy/ext/associationproxy.py | |
| parent | 191dd0055c05f51fa985d4e24f107faa58743022 (diff) | |
| parent | 66a246bd31730d53fb6b0e606d67ea4247f5e56c (diff) | |
| download | sqlalchemy-14eae5108d655e71bb80572109b4cd8f8a0fe51c.tar.gz | |
Merge "Default to using current mapped class as owner if none found"
Diffstat (limited to 'lib/sqlalchemy/ext/associationproxy.py')
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 7 |
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: |
