Adam Feuer <[email protected]> wrote:
> On Tue, Dec 30, 2014 at 4:09 PM, Michael Bayer <[email protected] > <mailto:[email protected]>> wrote: > you either need to take order_by off the relationship(), probably the best > idea here if ordering isn’t important, or otherwise skip joinedload(), write > out the joins yourself and use contains_eager() > (http://docs.sqlalchemy.org/en/rel_0_9/orm/loading_relationships.html?highlight=contains_eager#contains-eager > > <http://docs.sqlalchemy.org/en/rel_0_9/orm/loading_relationships.html?highlight=contains_eager#contains-eager>). > > Michael, > > Thanks for the ideas, we'll try them. Not sure I can remove the order_by > relationship because we need the order other places... if I remove that, I > will have to add sorting in each of the other places. But it might be worth > it. > > I think the manual joins and contains_eager may be better for us. Will that > work because the manual joins and contains_eager doesn't automatically > trigger adding the ORDER BY clauses? joinedload() is sort of a macro that creates the joins and other modifications to the query (such as ORDER BY the relationship), applies aliases to each of those parts so that there’s no chance of them conflicting with anything on the query, and then routes the columns from those extra FROM clauses into collections and related objects. contains_eager() does just the very last part of that. The first two parts, writing the joins and orderings and potentially aliasing them (or not), is up to you in that case, so you retain full control over how the query is rendered. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
