[sqlalchemy] Re: Cannot use add_entity to add result from subquery?

2009-07-15 Thread The Devil's Programmer
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

[sqlalchemy] How to filter by the result of a subquery?

2009-07-15 Thread The Devil's Programmer
I am currently performing a query with a joined subquery that gets the sum of votes on an article. The problem is that when I try to filter based on the result of that subquery, i get errors. Code outlining problem (very simple) - http://pastebin.com/m48905db6 Please tell me I don't have to

[sqlalchemy] Re: How to filter by the result of a subquery?

2009-07-15 Thread The Devil's Programmer
to start. The Devil's Programmer wrote: I am currently performing a query with a joined subquery that gets the sum of votes on an article. The problem is that when I try to filter based on the result of that subquery, i get errors. Code outlining problem (very simple) -http

[sqlalchemy] Question about joins and how the data is returned by the Query class

2009-07-14 Thread The Devil's Programmer
In my controller I have: query = session.query(Article, Category, User, UserVote) query = query.outerjoin((UserVote, and_ (Article.id==UserVote.article_id, UserVote.voter==currently_logged_in_user))) query = query.outerjoin((Category, Article.category_id == Category.id)) query =

[sqlalchemy] Question about joins and how the data is returned by the Query class

2009-07-14 Thread The Devil's Programmer
In my controller I have: query = session.query(Article, Category, User, UserVote) query = query.outerjoin((UserVote, and_ (Article.id==UserVote.article_id, UserVote.voter==currently_logged_in_user))) query = query.outerjoin((Category, Article.category_id == Category.id)) query =

[sqlalchemy] Cannot use add_entity to add result from subquery?

2009-07-14 Thread The Devil's Programmer
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 =

[sqlalchemy] Re: Question about joins and how the data is returned by the Query class

2009-07-14 Thread The Devil's Programmer
Thanks, works like a charm :) On Jul 15, 2:27 am, Michael Bayer mike...@zzzcomputing.com wrote: The Devil's Programmer wrote: So what I am trying to figure out, is if there is a way to have the query return None in place of the missing UserVote when the user is not logged in? I'm

[sqlalchemy] Re: Cannot use add_entity to add result from subquery?

2009-07-14 Thread The Devil's Programmer
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

[sqlalchemy] Re: Cannot use add_entity to add result from subquery?

2009-07-14 Thread The Devil's Programmer
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