On Sunday 22 June 2008 19:48:55 Michael Bayer wrote: > 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), ....
ok i got the query to yield something by r = r.outerjoin( selector, id=somid) r = r.add_column( getattr( selklas, extra_attrname), id=someid ) but now iterate_instances() fails tryin to put a row consisting of objects and plain unhashable column-values (in my case: set()) into an ordered set. i see in 0.5 the code is somewhat different although it will still try to put column-values in a set, and they may not be hashable. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---