subquery eager load fails with aliased classes

Issue #1964 resolved
Mike Bayer repo owner created an issue

possible patch, need to dig in to see whats being determined here, if behavior is as expected:

diff -r 6dfdc9473977c6d94ff1eb090b96ec42f1b2d66d lib/sqlalchemy/orm/strategies.py
--- a/lib/sqlalchemy/orm/strategies.py  Tue Nov 09 12:19:11 2010 -0500
+++ b/lib/sqlalchemy/orm/strategies.py  Thu Nov 11 12:41:34 2010 -0500
@@ -741,13 +741,17 @@
                                 context.query)

         # determine attributes of the leftmost mapper
-        if self.parent.isa(subq_path[0](0)) and self.key==subq_path[1](1):
+        
+        
+        subq_mapper, subq_selectable, subq_isalias = mapperutil._entity_info(subq_path[0](0))
+        
+        if self.parent.isa(subq_mapper) and self.key==subq_path[1](1):
             leftmost_mapper, leftmost_prop = \
                                     self.parent, self.parent_property
         else:
             leftmost_mapper, leftmost_prop = \
-                                    subq_path[0](0), \
-                                    subq_path[0](0).get_property(subq_path[1](1))
+                                    subq_mapper, \
+                                    subq_mapper.get_property(subq_path[1](1))
         leftmost_cols, remote_cols = self._local_remote_columns(leftmost_prop)

Comments (5)

  1. Mike Bayer reporter

    actually this still fails:

            q = sess.query(u).\
                            options(subqueryload_all(u.addresses, Address.dingalings))
    
  2. Log in to comment