On 6/2/07, Gaetan de Menten <[EMAIL PROTECTED]> wrote:
> IMHO, this solves my use case nicely. It's slightly longer than what I
> proposed but doesn't reach my internal "this_is_too_long_to_type"
> threshold and it's more explicit...
>
> So for me it's a +1 for that solution (along with documenting the
> joinpoint behavior ;-)).

Hmmm, after some more thoughts there is one little aspect of that
which bothers me: once you joined to something, you can't add
filtering criteria on the initial table/class. This is actually one of
the features I disliked about the current code. It might be rare use
case but I, for one, like to be able to construct queries in any
order, so that I can factor out the common part and store it somewhere
then add what is specific at a later point. Here, if the specific part
is about the initial table, I'm screwed. Adding a method to just
move/reset the joinpoint would solve this, though I find it ugly.
Better than nothing though.

This would look like this:

q = session.query(User).join(['orders', 'items']).filter_by(item_name='foo').
user_query = q.join(['addresses']).filter_by(email_address='[EMAIL 
PROTECTED]').reset_joinpoint()

users = user_query.filter_by(name='Foo').list()

>
> On 6/2/07, Michael Bayer <[EMAIL PROTECTED]> wrote:
> >
> >
> > plus *another* option to think about here, which was actually my
> > first (suppressed) instinct, but now i just saw that Hibernate "sort
> > of" does this, is to *keep* the "joinpoint" in and just have the
> > "join" function reset the "joinpoint" on each invocation.
> >
> > so,
> >
> > session.query(User).join(['orders', 'items']).filter_by
> > (item_name='foo').join(['addresses']).filter_by
> > (email_address='[EMAIL PROTECTED]').list()
> >
> > at the moment, this seems intuitive to me.  but i dont know if itll
> > stay that way.  i do like that each method has a single type of
> > argument, as opposed to filter_by(qualifier, **kwargs).
>
> --
> Gaëtan de Menten
> http://openhex.org
>


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