>> hmmm, specify explicitly? >> e.g. query(A).eagerload( B.address) >> >> joined-inh via left-outer-join is enough, no need for polymunion.
>> i dont know how the current machinery for eagerload works, but imo >> knowing your level of lookahead-design, it should not be hard to >> apply that machinery over a polymorphic mapper/query? > > theres plenty of much higher priority issues than this one in the > queue...considering that you can already get the results you want with > this one using direct SQL..... right.. i've hacked something that seems to work; It's about 20 lines split in orm.query and orm.interfaces: - such special eagerloaders are requested as query.eagerload( B.address) - and not just the name/path - query-compile calling context.exec_withpath(...) iterates over all self.mapper properties (not only select_mapper's), plus all eagerloaders of above type (i.e. non-names). Thus the 4 cases are covered: A has address / query(B).eagerload('address') #works before A has address / query(A).eagerload('address') #new - did not work before B has address / query(B).eagerload('address') #works before B has address / query(A).eagerload(B.address) #new - not possible before (in all these B inherits A via joined inheritance; A is polymorphic via left-outer-joins) i'm absolutely sure that this is not the completely right thing - that's what i got from the machinery-src in 2 hours - but it is something as a start... sure it needs correctness tests etc of the sorts. g'night svilen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
Index: orm/query.py =================================================================== --- orm/query.py (revision 4032) +++ orm/query.py (working copy) @@ -991,10 +991,20 @@ # give all the attached properties a chance to modify the query # TODO: doing this off the select_mapper. if its the polymorphic mapper, then # it has no relations() on it. should we compile those too into the query ? (i.e. eagerloads) - for value in self.select_mapper.iterate_properties: + + for value in self.mapper.iterate_properties: + if self._only_load_props and value.key not in self._only_load_props: + continue + context.exec_with_path(self.mapper, value.key, value.setup, context, only_load_props=self._only_load_props) + for (mp, key) in self._eager_loaders: + if isinstance( key, str): continue #plain + value = key.property if self._only_load_props and value.key not in self._only_load_props: continue - context.exec_with_path(self.select_mapper, value.key, value.setup, context, only_load_props=self._only_load_props) + context.exec_with_path(self.mapper, key, value.setup, context, only_load_props=self._only_load_props) # additional entities/columns, add those to selection criterion for tup in self._entities: Index: orm/interfaces.py =================================================================== --- orm/interfaces.py (revision 4032) +++ orm/interfaces.py (working copy) @@ -594,6 +599,7 @@ raise exceptions.ArgumentError("Can't find entity %s in Query. Current list: %r" % (str(mapper), [str(m) for m in [query.mapper] + query._entities])) else: mapper = query.mapper + if isinstance( self.key,str): for token in self.key.split('.'): if current_path and token == current_path[1]: current_path = current_path[2:] @@ -604,6 +610,16 @@ path = build_path(mapper, prop.key, path) l.append(path) mapper = getattr(prop, 'mapper', None) + else: + ia = self.key + key = ia.impl.key + #from sqlalchemy.orm import class_mapper + #mp = mapper#class_mapper( ia.impl.class_) #assert mp inherits mapper? + self.key = key + path = build_path(mapper, ia, path) + l.append(path) return l PropertyOption.logger = logging.class_logger(PropertyOption)