summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/interfaces.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-17 18:48:17 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-17 19:42:43 -0400
commit7f82168cb6b0f0e22d387ffeca1ae82f526c2f29 (patch)
tree1ef9195524e6de9fc1e49e07795398538ac20043 /lib/sqlalchemy/orm/interfaces.py
parent42d58f8b6e67c01827f1eed283e23067bbdb848d (diff)
downloadsqlalchemy-7f82168cb6b0f0e22d387ffeca1ae82f526c2f29.tar.gz
- rework PropComparator.adapted() to be PropComparator.adapt_to_entity(),
passes in AliasedInsp and allows more flexibility. - rework the AliasedClass/AliasedInsp relationship so that AliasedInsp has all state and functionality. AliasedClass is just a facade. [ticket:2756]
Diffstat (limited to 'lib/sqlalchemy/orm/interfaces.py')
-rw-r--r--lib/sqlalchemy/orm/interfaces.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 396f234c4..150277be2 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -381,21 +381,30 @@ class PropComparator(operators.ColumnOperators):
"""
- def __init__(self, prop, parentmapper, adapter=None):
+ def __init__(self, prop, parentmapper, adapt_to_entity=None):
self.prop = self.property = prop
self._parentmapper = parentmapper
- self.adapter = adapter
+ self._adapt_to_entity = adapt_to_entity
def __clause_element__(self):
raise NotImplementedError("%r" % self)
- def adapted(self, adapter):
+ def adapt_to_entity(self, adapt_to_entity):
"""Return a copy of this PropComparator which will use the given
- adaption function on the local side of generated expressions.
-
+ :class:`.AliasedInsp` to produce corresponding expressions.
"""
+ return self.__class__(self.prop, self._parentmapper, adapt_to_entity)
+
+ @property
+ def adapter(self):
+ """Produce a callable that adapts column expressions
+ to suit an aliased version of this comparator.
- return self.__class__(self.prop, self._parentmapper, adapter)
+ """
+ if self._adapt_to_entity is None:
+ return None
+ else:
+ return self._adapt_to_entity._adapt_element
@util.memoized_property
def info(self):