yeah that or keep track of the initial join object before you put it  
in the select.

On Mar 5, 2007, at 5:59 PM, Dennis wrote:

>
> I did find a slight hack:
>
> query.append_from (
>  query.froms._list[0].outerjoin(.... etc ... ) )
>
> -Dennis
>
> On Mar 5, 3:54 pm, "Dennis" <[EMAIL PROTECTED]> wrote:
>> Actually, I'm still having a problem because the primary object is
>> already a join and the next object that I append gets listed twice.
>>
>> Example
>>
>> sel=select([a,b], from_obj=[a.outerjoin(b)])
>> sel.append( a.outerjoin(c,somecriteriaforthejoin))
>> str(sel)
>> SELECT ,,, FROM a LEFT OUTER JOIN b ON .... , a LEFT OUTER JOIN c
>> ON ...
>> sel.execute()
>> SQLError: (ProgrammingError) table name "a" specified more than once
>>
>> What I really need is: a.outerjoin(b).outerjoin(c)
>> That is what I can't seem to find a way to dynamically generate.
>>
>> Thanks
>> -Dennis
>>
>> On Mar 5, 3:16 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
>>
>>> there is append_from()
>>
>>> joins know how to find their "components" that are already in the
>>> selectable and replace them.
>>
>>> On Mar 5, 2007, at 4:38 PM, Dennis wrote:
>>
>>>> I'm playing around with dynamically building a query.  I can append
>>>> columns, where clauses, from objects etc... but what about the case
>>>> where I want to modify the from obj with a join?
>>
>>>> For example I can do this:
>>
>>>> sel=select()
>>>> sel.append_from(a)
>>>> sel.append_from(b)
>>>> sel.append_whereclause(a.c.id==b.c.id)
>>
>>>> That won't work for an outerjoin though.  I have a query that works
>>>> like this now:
>>
>>>> select ( [...], from_obj=[a.outerjoin(b)] )
>>
>>>> but I can't figure out a way to add the outerjoin dynamically.  I
>>>> looked at clause visitors but there doesn't seem like a way to
>>>> actually modify an existing join.
>>
>>>> Any thoughts?
>>
>>>> Thanks
>>>> Dennis
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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