No. I'm want to edit the target of the 'select' from an existing query. For many select operations, I need three variations
- the full Objects - just the ObjectIds - a count of the objects ( which is sometimes faster as an explicit "select obj.id" than a "select obj" , so i can influence the pg query planner more ) At least 95% of our application hits an "internal api" that generates the SqlAlchemy queries, instead of using SqlAlchemy directly. This just gives us a more standard interface as we change filtering defaults or make underlying db changes. Here's an example of what I have occurring more than a few dozen times: def _core_Foos( dbSession, kw_a=True, kw_b=False, kw_c=True, ids_only=false, for_count=False): if ids_only or for_count: query = dbSession.query( Foo.id ) else: query = dbSession.query( Foo ) ### ### lots of complex filtering and joining based on kwags here ### dozens and dozens of lines ### if for_count : return query query = query\ .order_by( Foo.id.desc() )\ .limit( limit )\ .offset( offset ) return query def get_Foos( dbSession, **kwargs ): query = _core_Foos( dbSession, ids_only = True, **kwargs ) return query.all() def get_fooIds( dbSession, **kwargs ): query = _core_Foos( dbSession, ids_only = True, **kwargs ) return [ i[0] for i in query.all() ] def get_count_fooIds( dbSession, **kwargs ): query = _core_Foos( dbSession, for_count = True, **kwargs ) return query.count() This works really well. I just don't really like that I start the query off by selecting an id or object(ie, all columns). I'm trying to figure out if there are better ways to handle this. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.