diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-01 00:08:55 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-01 00:08:55 -0400 |
commit | b99480aac23fdd4e0ef3633703ca5b32ea49805a (patch) | |
tree | 9916ba5a34b365e073eb38a4d46222ebbbb25151 /lib/sqlalchemy/orm/mapper.py | |
parent | 2cc7d704be011ebf16181f67da27096a603e2a12 (diff) | |
download | sqlalchemy-b99480aac23fdd4e0ef3633703ca5b32ea49805a.tar.gz |
- [bug] with_polymorphic() produces JOINs
in the correct order and with correct inheriting
tables in the case of sending multi-level
subclasses in an arbitrary order or with
intermediary classes missing. [ticket:1900]
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
-rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 4ff26cc21..0254933c2 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1347,12 +1347,19 @@ class Mapper(_InspectionAttr): if spec == '*': mappers = list(self.self_and_descendants) elif spec: - mappers = [_class_to_mapper(m) for m in util.to_list(spec)] - for m in mappers: + mappers = set() + for m in util.to_list(spec): + m = _class_to_mapper(m) if not m.isa(self): raise sa_exc.InvalidRequestError( "%r does not inherit from %r" % (m, self)) + + if selectable is None: + mappers.update(m.iterate_to_root()) + else: + mappers.add(m) + mappers = [m for m in self.self_and_descendants if m in mappers] else: mappers = [] |