Thanks! On 8 Maj, 16:24, Michael Bayer <mike...@zzzcomputing.com> wrote: > On May 8, 2010, at 9:40 AM, Adam Dziendziel wrote: > > > > > Hi, > > > I would like to be able to write a query like: > > > session.query(Post).recent().include_authors().limit(10).all() > > > that would translate into: > > > session.query(Post).order_by(Post.created_at.desc()).options(joinedload('author')).limit(10).all() > > > The former code hides persistence details from the user. Methods > > recent() and include_authors() are specific for the Post class. > > > Is this possible to achieve that kind of syntax on top of SQLAlchemy, > > for example, by extending the Query class? I know that I can pass a > > custom Query class to the constructor of a Session. It is possible to > > set a different Query class for each mapped class? > > sure, pass in a callable to the session for query_cls which does whatever > translation to an actual Query instance you'd like. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://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 sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.