The Devil's Programmer wrote:
>
> I can do this -
>
> comment_count_subquery = meta.Session.query(Comment.article_id,
> func.count('*').label('article_comment_count')).group_by
> (Comment.article_id).subquery()
> query = meta.Session.query(Article,
> comment_count_subquery.c.article_comment_count)
>
> but when I do it like this -
>
> query = meta.Session.query(Article)
> comment_count_subquery = meta.Session.query(Comment.article_id,
> func.count('*').label('article_comment_count')).group_by
> (Comment.article_id).subquery()
> query.add_entity(comment_count_subquery.c.article_comment_count)

you'd want "add_column()" to add a column after the fact to a Query. 
add_entity() and add_column() are both a little old school.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to