On Jun 22, 2008, at 12:51 PM, [EMAIL PROTECTED] wrote:
> > On Sunday 22 June 2008 18:51:44 Michael Bayer wrote: >> On Jun 22, 2008, at 8:27 AM, [EMAIL PROTECTED] wrote: >>> hi >>> i want to fetch/eagerload just one column off a related object. >>> e.g. if >>> A.b pointing to B and B having x,y,z, i want to get all As and >>> the A.b.x, and nothing else from B. >>> it even doesnot actualy matter if it will be really A.b.x or just >>> some A.new_bx made-up column/attribute. >>> >>> can? >> >> you can: >> >> query(A, B.x).join(A.bs).all() > how do i alias those as they are all similar (e.g. B.x and C.x etc) > > i do (pseudocode): > r = query(A)... > extra_name = ... #the above 'x' present in all B,C,D,... > for selector,selklas in dict(b=B,c=C,d=D).items(): > r = r.add_column( getattr( selklas, extra_attrname) ) > r = r.outerjoin( selector) > > the error is: > Ambiguous join for entity 'B.x'; specify id=<someid> to > query.join()/query.add_column(), or use the aliased() function to use > explicit class aliases. Balias = aliased(B) Calias = aliased(C) query(A, Balias.x, Calias.x), .... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---