diff options
author | Matthias Urlichs <matthias@urlichs.de> | 2014-05-19 03:08:42 +0200 |
---|---|---|
committer | Matthias Urlichs <matthias@urlichs.de> | 2014-05-19 03:08:42 +0200 |
commit | 611d529537194dd95a3114d627aaf4eab449a8cb (patch) | |
tree | 9d20b7465b1bf636f2da121c90bde8e90c6f7eee | |
parent | 460465a8749aecff761e1c81c77d7c23e8672789 (diff) | |
download | sqlalchemy-pr/92.tar.gz |
Add a _proxyImpl helper classpr/92
formalchemy does the following:
if isinstance(self._impl, ScalarAttributeImpl) or self._impl.__class__.__name__ == '_ProxyImpl': # ProxyImpl is a one-off class for each synonym, can't import it
# normal property, mapped to a single column from the main table
prop = getattr(self._property, '_proxied_property', None)
if prop is None:
prop = self._property
return tuple(prop.local_columns)
With this patch, this test can be replaced with
if isinstance(self._impl, (ScalarAttributeImpl,ProxyImpl):
…
-rw-r--r-- | lib/sqlalchemy/orm/descriptor_props.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py index 9ecc9bb62..c4d6aac27 100644 --- a/lib/sqlalchemy/orm/descriptor_props.py +++ b/lib/sqlalchemy/orm/descriptor_props.py @@ -18,6 +18,9 @@ from ..sql import expression from . import properties from . import query +class ProxyImpl(object): + """A helper class for detecting whether an attribute is a proxy""" + pass class DescriptorProperty(MapperProperty): """:class:`.MapperProperty` which proxies access to a @@ -28,7 +31,7 @@ class DescriptorProperty(MapperProperty): def instrument_class(self, mapper): prop = self - class _ProxyImpl(object): + class _ProxyImpl(ProxyImpl): accepts_scalar_loader = False expire_missing = True collection = False |