I tried
names.select (exists ([names.c.id], and_(names.c.id == obj_tags.c.name_id, obj_tags.c.parent_id==Taggable.c.id , Taggable.c.id == query.compile() ) however, I am getting too many fields back with the error "subquery must return only one column" Any suggestion on how to ask for only the id column? Thanks, Kris On Nov 27, 8:32 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Nov 27, 2007, at 8:18 PM, kris wrote: > > > > > > > I am trying to do a select on the results an ORM subquery. > > > The following query is prepared in one part the program > > query = session.query(Taggable).filter (....) > > > Elswere I try to get the unique names associated with all previously > > selected > > Taggable obects. > > > names.select (exists ([names.c.id], > > and_(names.c.id == obj_tags.c.name_id, > > obj_tags.c.parent_id==Taggable.c.id , > > Taggable.c.id in query) > > ^^^^^^^^^^^^^ > > > Unfortunately, I have not found the solution to the marked expression, > > which I think can be expressed as a subquery. > > > Is this possible? Is there a way to pull the select expression out of > > the ORM > > query object? > > at the moment you can pull it out by saying query.compile(), which > will give you a select(). we do have a trac ticket that would > actually provide a "query" operator on Query which would automatically > wrap the current selection in a subquery and continue to query from > there so we might be adding that feature eventually. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---