On 4/26/07, Michael Bayer <[EMAIL PROTECTED]> wrote:

> On Apr 26, 2007, at 4:40 AM, Gaetan de Menten wrote:
>
> >>         - you have an aggregate function there.  wheres the GROUP
> >> BY ? not
> >> just of the main table's columns but any other columns named for
> >> eager loads.
> >
> > It's unneeded in my example, and for cases where this would be needed,
> > I think we could easily enhance the StatementProperty so that you can
> > add anything to the parent query: join conditions, etc...
> >
>
> how do you select multiple columns, where only one column is used in
> an aggregate function, and no GROUP BY?

The answer is: you don't. This is a subselect. Here is, for example,
the query generated for the lazy version:

SELECT (SELECT sum(tags.score1 * tags.score2) FROM tags WHERE
tags.user_id = users.id) AS user_score, users.id AS users_id,
users.name AS users_name
FROM users ORDER BY users.id

> are you using mysql only ?

Nope.

By the way, the patch I did is buggier than I thought for eager
relationships. I thought it broke only for subselects, but the simple
"statement" I provided in my example doesn't work nicely either
(because it needlessly joins to the "tags" table). So the result are
correct but it's awfull behind the scene. :)

But nevermind the patch I did. I realize now it's pretty much useless.
But what about the approach I discussed in my previous mail? (using
what is in the relation loaders but without creating the instances)

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

Reply via email to