]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- eager loader calls select_mapper so that poly rulesets get picked up
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 8 Jun 2007 03:17:11 +0000 (03:17 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 8 Jun 2007 03:17:11 +0000 (03:17 +0000)
- changed polymorph example to use a single set of outerjoins

CHANGES
examples/polymorph/polymorph.py
lib/sqlalchemy/orm/strategies.py

diff --git a/CHANGES b/CHANGES
index f074b27f753ee9554cb9c38e325574994c0e7f41..120bd6e23fa346e445ed8135b55c121e45c5c545 100644 (file)
--- 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]
index 6c4f0aae6a732f46fcd7e04109b6d1acbe5e0411..67138b0847048b6c2a1b7d60edfbccdc8861d883 100644 (file)
@@ -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')
 
index 727d949bc60f573acf8da4f77a1f7aca4251f0df..462954f6bbe6582b42e27c4404ca3ea9b8beb005 100644 (file)
@@ -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)