On Nov 9, 2008, at 4:46 AM, Cito wrote:

>
> On 8 Nov., 22:03, Michael Bayer <[EMAIL PROTECTED]> wrote:
>> oh sorry, also count() is meant to count instances of a single kind  
>> of
>> object.  So in fact you should be saying:
>>
>> session.query(UserRss).join(Rss, item).count()
>
> This question is actually coming from the TurboGears group. The
> problem here is that our pagination mechanism takes an existing query
> and checks its result size with count(). I.e. we have no influence on
> the actual query, we just assume that if you can get all() or slices
> from the query that you can also count() its results. This had worked
> all the time up to 0.4.8, but with 0.5 it doesn't work any more.


Assuming your joins are many-to-ones, you can get a straight row count  
using query(*anything).value(func.count('*')), optionally adding  
distinct() before you call value().   This is a better strategy than  
using count() in any case since Query.count() still has a behavioral  
contract I'm not totally happy with, and you'll get better control  
over what it is you actually want to count.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to