[sqlalchemy] subquery as a mapper property

2011-03-16 Thread hoesley
I am trying to create a property on a mapped class which basically executes a subquery. Here is what I'm trying to do in non-working pseudo code: mapper(OrderChain, Table('order_chains',self.meta, autoload=True), properties={'entries': relation(OrderChainEntry,

Re: [sqlalchemy] subquery as a mapper property

2011-03-16 Thread Michael Bayer
this kind of pattern is usually handled by column_property(), assuming you can correlate your subquery to the parent within the WHERE clause such that the return value is a scalar. Below if you really just wanted the first row you'd want to say limit(1). If you really want that exact same