]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
restore common_parent logic in correspoinds_to, fixes [ticket:1657]
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Jan 2010 19:04:50 +0000 (19:04 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Jan 2010 19:04:50 +0000 (19:04 +0000)
lib/sqlalchemy/orm/query.py
test/orm/inheritance/test_query.py

index fc83f91959d7d87e235dcf0b8b0db51e5d48321c..7be0680197e87f379c8407cf8743b7001146ede5 100644 (file)
@@ -2038,10 +2038,10 @@ class _MapperEntity(_QueryEntity):
             self.adapter = query._get_polymorphic_adapter(self, from_obj)
 
     def corresponds_to(self, entity):
-        if _is_aliased_class(entity):
+        if _is_aliased_class(entity) or self.is_aliased_class:
             return entity is self.path_entity
         else:
-            return entity.isa(self.path_entity)
+            return entity.common_parent(self.path_entity)
 
     def adapt_to_selectable(self, query, sel):
         query._entities.append(self)
index 1a7d09e92ecd1fb41b40eb44f710d467453de7da..256eaefa6a88296d7b672b7d17aa4351a5dd223f 100644 (file)
@@ -503,6 +503,12 @@ def _produce_test(select_type):
                 )
             self.assert_sql_count(testing.db, go, 1)
 
+            
+        def test_query_subclass_join_to_base_relation(self):
+            sess = create_session()
+            # non-polymorphic
+            eq_(sess.query(Engineer).join(Person.paperwork).all(), [e1, e2, e3])
+
         def test_join_to_subclass(self):
             sess = create_session()
             eq_(sess.query(Company).join(('employees', people.join(engineers))).filter(Engineer.primary_language=='java').all(), [c1])