Here is an experimental patch to add generative aggregate methods on
query objects.

My use case is that I have a class which is often queried with a sum
query, from different places. But those different places usually add a
filter on top of that basic query. And since I don't like repeating
myself, I wanted a way to factor the common part.

Here is some (untested) example:

score_query = Query(Tag).sum_clause(tags_table.c.score1 * tags_table.c.score2)
fun_score_query = score_query.filter_by(name='fun')

[... on another place ...]

user_fun_score = fun_score_query.filter_by(user=self).scalar()

If you agree with the concept and way to do it, I'd happily complete
it for the other aggregates and document it.

PS: for such new feature suggestions, do you prefer if I add a ticket
directly or if I discuss the thing here first?
-- 
Gaƫtan de Menten
http://openhex.org

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

Attachment: generative_aggregate.diff
Description: application/text

Reply via email to