From 4215a5f20003e0a9d2633464ea7073472659a315 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 8 Jun 2007 03:17:11 +0000 Subject: [PATCH] - eager loader calls select_mapper so that poly rulesets get picked up - changed polymorph example to use a single set of outerjoins --- CHANGES | 7 +++++++ examples/polymorph/polymorph.py | 13 +++---------- lib/sqlalchemy/orm/strategies.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index f074b27f75..120bd6e23f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +- orm + - remember all that stuff about polymorphic_union ? for + joined table inheritance ? Funny thing... + You sort of don't need it for joined table inheritance, you + can just string all the tables together via outerjoin(). + The UNION still applies if concrete tables are involved, + though (since nothing to join them on). - sql - long-identifier detection fixed to use > rather than >= for max ident length [ticket:589] diff --git a/examples/polymorph/polymorph.py b/examples/polymorph/polymorph.py index 6c4f0aae6a..67138b0847 100644 --- a/examples/polymorph/polymorph.py +++ b/examples/polymorph/polymorph.py @@ -55,16 +55,9 @@ class Company(object): return "Company %s" % self.name -# create a union that represents both types of joins. -person_join = polymorphic_union( - { - 'engineer':people.join(engineers), - 'manager':people.join(managers), - 'person':people.select(people.c.type=='person'), - }, None, 'pjoin') - -#person_mapper = mapper(Person, people, select_table=person_join, polymorphic_on=person_join.c.type, polymorphic_identity='person') -person_mapper = mapper(Person, people, select_table=person_join,polymorphic_on=person_join.c.type, polymorphic_identity='person') +person_join = people.outerjoin(engineers).outerjoin(managers) + +person_mapper = mapper(Person, people, select_table=person_join,polymorphic_on=people.c.type, polymorphic_identity='person') mapper(Engineer, engineers, inherits=person_mapper, polymorphic_identity='engineer') mapper(Manager, managers, inherits=person_mapper, polymorphic_identity='manager') diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 727d949bc6..462954f6bb 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -607,7 +607,7 @@ class EagerLoader(AbstractRelationLoader): result_list = selectcontext.attributes[(instance, self.key)] if self._should_log_debug: self.logger.debug("eagerload list instance on %s" % mapperutil.attribute_str(instance, self.key)) - self.mapper._instance(selectcontext, decorated_row, result_list) + self.select_mapper._instance(selectcontext, decorated_row, result_list) finally: selectcontext.recursion_stack.remove(self) -- 2.47.2