Kyle Schaffrick wrote:
>
> On Mon, 13 Jul 2009 19:18:39 -0400
> "Michael Bayer" <mike...@zzzcomputing.com> wrote:
>>
>> Brad Wells wrote:
>> >
>> > Is it possible to perform a query.count() on a query with a labeled
>> > column expression without count() adding the subselect? I need to
>> > filter on the value of the expression and get a count for a paged
>> > view.
>>
>> although reading the docs to query.count(), its pretty clear as far as
>> querying mapped entities vs. column expressions.  I think it might
>> just need very clear documentation that, for counting anything more
>> complex than query(Foo).filter().count(), you should be using column
>> expressions.
>>
>
> Idea: query.count() could be superseded by len(query) so that it clearly
> suggests the intended use case of "how many things are returned by this
> query" instead of the wierd SQL concept of count(), which should be
> served by column expressions. It also nicely aligns it with other Python
> collection-y things.

len(query) forces us to play games with the __iter__ method on query such
that it can't be a real iterator.

Also, the theme here is query.count() often does not do what you expect. 
making it invisible just makes that fact harder to realize.

as far as "weird SQL concepts", SQLA's orm is intentionally SQL-specific. 
  hence it has other "weird" things like join(), outerjoin(), group_by(),
having(), etc.


--~--~---------~--~----~------------~-------~--~----~
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