ok so the problem was that I was just calling query.add_column()
without grabbing the result, ie.. query = query....

*facepalm* rookie mistake



On Jul 15, 10:41 am, "The Devil's Programmer"
<thedevilsprogram...@gmail.com> wrote:
> here is my code
>
> http://pastebin.com/m13075cc9
>
> if that helps
>
> On Jul 15, 10:22 am, "The Devil's Programmer"
>
> <thedevilsprogram...@gmail.com> wrote:
> > well instead of returning an iterable array of Articles, its just
> > returning a single Article
>
> > On Jul 15, 10:17 am, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
>
> > > The Devil's Programmer wrote:
>
> > > > using add_column does not seem to work the same as including both
> > > > items in the query [like below]
>
> > > > query = meta.Session.query(Article,
> > > > comment_count_subquery.c.article_comment_count)
>
> > > > it does not return an iterable result
>
> > > > is there any way to add subqueries to the query after the query has
> > > > been created, that replicates the functionality you would expect if
> > > > you had included both items in the initial query() call?
>
> > > add_column().  If you can be more specific what "does not seem to work the
> > > same", that would help.
>
> > > > On Jul 15, 9:05 am, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
> > > >> 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