Alisue wrote: > > Oops. I found the solution with my self. > > like below. > > c.paginator = paginate.Page( > meta.Session.query(Article).select_from(query.subquery()), > page=int(request.params.get('page',1)), > items_per_page=int(request.params.get('items_per_page', 10)) > ) > > But why can't I do like below? or similar way? > > query.select_from(query.subquery())
that is what query.from_self() does. > > > On 6ζ22ζ₯, εεΎ6:34, Alisue > <hello.goodbye.by.beat...@gmail.com> wrote: >> I have a Article table may relate with a Room table and I want to find >> Article sometime with Room.name. >> So I wrote the code like below. >> >> query = meta.Session.query(Article) >> query = query.outerjoin('rooms') >> if room_name is not None: >> query = query.filter(Room.name == room_name) >> query = query.group_by(Article.id) >> return query >> >> A result is correct. I got all Article name without room_name and >> Articles which has rooms named as room_name. >> >> However, when I use this query with webhelpers.paginate(http:// >> beta.pylonshq.com/docs/ja/0.9.7/thirdparty/webhelpers/paginate/ >> #webhelpers.paginate.Page), everything goes wrong. 'paginator' doesn't >> work correct. >> >> So I chacked logs and find this output. >> 'SELECT COUNT(1) AS count_1 FROM articles LEFT OUTER JOIN rooms ON >> articles.id = rooms.article_id GROUP BY articles.id' >> >> This is might made by .count() function of sqlalchemy in somewhere in >> webhelpers.paginate code I think. However what I want to get is >> 'SELECT COUNT(1) AS count_1 FROM (SELECT * FROM articles LEFT OUTER >> JOIN rooms ON articles.id = rooms.article_id GROUP BY articles.id)' >> >> I have no idea to fix this problem. Anyone? thank you. >> >> SQLAlchemy: 0.5.4 >> Pylons: 0.9.7 > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---