On May 3, 2012, at 8:27 PM, Michael Bayer wrote: > > OK, here is better than using fold_equivalents. This might make it into 0.8 > in some form: > > from sqlalchemy.sql.util import reduce_columns > > def reduced(query): > stmt = query.statement > return stmt.with_only_columns(reduce_columns(stmt.inner_columns)) > > sq = reduced(s.query(BasePrAc)).alias() > > q = s.query(Post).join((sq, sq.c.id == Post.basePrAcId)).all() > print q > > > reduce_columns() will limit the set of columns in a list of columns to those > that are "equivalent" based on foreign key.
this is ticket #1729 moved up to 0.8. It will look like this: sq = s.query(BasePrAc).subquery(reduce_equivalents=True) thanks for the background on this ! > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > 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. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
