Just to be painfully complete the solution was: subquery = select([Taggable.c.id], query._criterion, from_obj= query._from_obj).as_scalar()
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_ ( subquery) )) which works in 0.4.1, but not in 0.3.11 Thanks for the help! Kris On Nov 27, 8:57 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Nov 27, 2007, at 11:51 PM, kris wrote: > > > > > 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? > > oh, well yeah now it will get slightly more tricky. you can pull out > the "WHERE" criterion by itself using query._criterion, but that wont > give you the joins anything else, i.e. > > select([mytable.c.somecolumn], query._criterion).as_scalar() > > if you have joins in there as well, you can get them like: > > select([mytable.c.somecolumn], query._criterion, > from_obj=query._from_obj).as_scalar() > > im not sure at the moment how/if this particular kind of operation > would be a regular query method....maybe query.generate_select() or > something.. also as_scalar() wraps the select in a "scalar-holding" > object that makes it act like a single column in expressions. its not > entirely needed but can be helpful. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---