Hello

I have a method with the following sqlalchemy request.

items = session.query(UserRss, Rss, Item).filter(
                 and_(Item.rss_id==Rss.id,
                      UserRss.user==user,
                      UserRss.rss_id==Rss.id,
                      Rss.id==Item.rss_id)
                 )
items = items.order_by(Item.updated.desc())

But when I use paginate I get the following error.
File "/opt/local/lib/python2.5/site-packages/TurboGears-1.1b1- 
py2.5.egg/turbogears/paginate.py", line 184, in decorated
     row_count = var_data.count() or 0
File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3- 
py2.5.egg/sqlalchemy/orm/query.py", line 1193, in count
     return self._col_aggregate(sql.literal_column('1'),  
sql.func.count, nested_cols=list(self._only_mapper_zero().primary_key))
File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3- 
py2.5.egg/sqlalchemy/orm/query.py", line 240, in _only_mapper_zero
     raise sa_exc.InvalidRequestError("This operation requires a Query  
against a single mapper.")
InvalidRequestError: This operation requires a Query against a single  
mapper.

It seems that count() cannot be used on that kind of requests with join.

 >>> items.count()Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3- 
py2.5.egg/sqlalchemy/orm/query.py", line 1193, in count
     return self._col_aggregate(sql.literal_column('1'),  
sql.func.count, nested_cols=list(self._only_mapper_zero().primary_key))
   File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0beta3- 
py2.5.egg/sqlalchemy/orm/query.py", line 240, in _only_mapper_zero
     raise sa_exc.InvalidRequestError("This operation requires a Query  
against a single mapper.")
InvalidRequestError: This operation requires a Query against a single  
mapper.
 >>>

How can I do to be able to use paginate with this kind of joins ?

-fred-




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to