There might be a way to do it off the relationships API entirely.  I do the 
following way all the time:

Join the child table, order by it, then use `contains_eager(childfield)` so 
sqlalchemy won't do another query for the child data

    return self.session.query(Reference) \ 
         .join(Periodical, Reference.periodical_id == Periodical.id)\
         .order_by(Periodical.id.asc())\ 
         .contains_eager('_periodical')\   # this lets sqlalchemy know you 
loaded the `_periodical` relationship, it will build those objects
         .all() 


-- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to