summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/descriptor_props.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/descriptor_props.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/descriptor_props.py')
-rw-r--r--lib/sqlalchemy/orm/descriptor_props.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py
index 97ca6d2eb..c58951339 100644
--- a/lib/sqlalchemy/orm/descriptor_props.py
+++ b/lib/sqlalchemy/orm/descriptor_props.py
@@ -326,16 +326,13 @@ class CompositeProperty(DescriptorProperty):
@util.memoized_property
def _comparable_elements(self):
- if self.adapter:
- # we need to do a little fudging here because
- # the adapter function we're given only accepts
- # ColumnElements, but our prop._comparable_elements is returning
- # InstrumentedAttribute, because we support the use case
- # of composites that refer to relationships. The better
- # solution here is to open up how AliasedClass interacts
- # with PropComparators so more context is available.
- return [self.adapter(x.__clause_element__())
- for x in self.prop._comparable_elements]
+ if self._adapt_to_entity:
+ return [
+ getattr(
+ self._adapt_to_entity.entity,
+ prop.key
+ ) for prop in self.prop._comparable_elements
+ ]
else:
return self.prop._comparable_elements
@@ -348,7 +345,7 @@ class CompositeProperty(DescriptorProperty):
a == b
for a, b in zip(self.prop._comparable_elements, values)
]
- if self.adapter:
+ if self._adapt_to_entity:
comparisons = [self.adapter(x) for x in comparisons]
return sql.and_(*comparisons)