summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-09-07 14:55:44 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-09-07 14:55:44 -0400
commitc52580dedef89f0b94274d7e49d4f4ab099c7bc6 (patch)
tree02a4c6cdd14c504a5f9ee263c2d81d638706b42d /lib/sqlalchemy/orm/util.py
parent7950270cf2b12807acd7c330b11dae36e50c3a28 (diff)
downloadsqlalchemy-ticket_3148.tar.gz
- rework ColumnAdapter and ORMAdapter to only provide the featuresticket_3148
we're now using; rework them fully so that their behavioral contract is consistent regarding adapter.traverse() vs. adapter.columns[], add a full suite of tests including advanced wrapping scenarios previously only covered by test/orm/test_froms.py and test/orm/inheritance/test_relationships.py - identify several cases where label._order_by_label_clause would be corrupted, e.g. due to adaption or annotation separately - add full tests for #3148
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index ed2011d4e..1bb6b571e 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -270,10 +270,8 @@ first()
class ORMAdapter(sql_util.ColumnAdapter):
- """Extends ColumnAdapter to accept ORM entities.
-
- The selectable is extracted from the given entity,
- and the AliasedClass if any is referenced.
+ """ColumnAdapter subclass which excludes adaptation of entities from
+ non-matching mappers.
"""
@@ -289,18 +287,18 @@ class ORMAdapter(sql_util.ColumnAdapter):
self.aliased_class = entity
else:
self.aliased_class = None
+
sql_util.ColumnAdapter.__init__(
self, selectable, equivalents, chain_to,
adapt_required=adapt_required,
allow_label_resolve=allow_label_resolve,
- anonymize_labels=anonymize_labels)
+ anonymize_labels=anonymize_labels,
+ include_fn=self._include_fn
+ )
- def replace(self, elem):
+ def _include_fn(self, elem):
entity = elem._annotations.get('parentmapper', None)
- if not entity or entity.isa(self.mapper):
- return sql_util.ColumnAdapter.replace(self, elem)
- else:
- return None
+ return not entity or entity.isa(self.mapper)
class AliasedClass(object):