Re: [sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-25 Thread Юрий Пайков
Michael, thank you for you reply, I expected you to mention from_self :) I know about it, it is a handy trick indeed But I deliberately don't use it, because this way I don't know how to mention a column which I want to filter on This is due to the fact, that it is calculated i.e. there is no

Re: [sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-25 Thread Юрий Пайков
Ok, I seemed to figure out how to deal with it - row_number_column = func.row_number().over( partition_by=Recipe.id ).label('row_number') query = query.add_column( row_number_column ) query = query.from_self().filter(row_number_column == 1) Using an explicit column construct суббота, 25

Re: [sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-25 Thread Mike Bayer
On 4/25/15 6:05 AM, Юрий Пайков wrote: Ok, I seemed to figure out how to deal with it - | row_number_column = func.row_number().over( partition_by=Recipe.id ).label('row_number') query = query.add_column( row_number_column ) query = query.from_self().filter(row_number_column == 1) |

[sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-24 Thread Пайков Юрий
 q = session.query(Recipe, func.avg(Recipe.field1).over(...)).join(...) I have a query which selects some mapped entity as well as other columns. I then refer to the name of that entity when working with the result of the query:for entry in q.all():  recipe=entry.Recipe   Now, I want to add

Re: [sqlalchemy] Preserve mapped entities after wrapping the query

2015-04-24 Thread Mike Bayer
On 4/24/15 5:25 PM, Пайков Юрий wrote: q = session.query(Recipe, func.avg(Recipe.field1).over(...)).join(...) I have a query which selects some mapped entity as well as other columns. I then refer to the name of that entity when working with the result of the query: for entry in q.all():