As I understand the confusion here, Ive added a check for "supports
execution" in rev 2289.  so that when you try to execute the "join",
it will raise an error.  originally i wasnt sure what would be
"executable" and what would not but im hoping its pretty well nailed
down at this point.  so far its:

Select/CompoundSelect
_Insert/_Update/_Delete
Alias (if its underlying target is a Select)
_TextClause


On Feb 2, 10:00 am, "Michael Bayer" <[EMAIL PROTECTED]> wrote:
> a join() by itself shouldnt be executed.  you need to call select()
> off of it (or use it inside the from_obj param of another select()).
> notice its not the parenthesis that are the problem, its the lack of
> an enclosing "SELECT ... FROM".
>
> On Feb 2, 5:04 am, "jlowery" <[EMAIL PROTECTED]> wrote:
>
> > I am building a SQL query one step at a time in different parts of my
> > application. I am using MySQL 4.1
>
> > Currently, the query being automatically built is:
>
> >  (SELECT doc_index.doc_id, doc_index.doc_type, doc_index.ref_id,
> > doc_index.create_date, doc_index.modified_date FROM doc_index) JOIN
> > snack ON doc_index.ref_id = snack.snack_id AND doc_index.doc_type = %s
> > JOIN drink ON doc_index.ref_id = drink.drink_id AND doc_index.doc_type
> > = %s
>
> > First, MySQL throws a syntax error because of the parenthesis around
> > the SELECT expression. Is there any way to turn that off?
>
> > Second, this has to be a LEFT JOIN, not a standard join, so something
> > like this:
>
> > SELECT doc_index.doc_id, doc_index.doc_type, doc_index.ref_id,
> > doc_index.create_date, doc_index.modified_date
> > FROM doc_index
> > LEFT JOIN snack ON doc_index.ref_id = snack.snack_id AND
> > doc_index.doc_type = %s
> > LEFT JOIN drink ON doc_index.ref_id = drink.drink_id AND
> > doc_index.doc_type = %s
>
> > Here is a condensed version of the code
>
> > stmt = doc_type_table.select()
>
> > join_table = get_join_table('widgets')
> > stmt = stmt.join(join_table,
> > SA.and_(doc_type_table.c.ref_id==join_table.primary_key[0],
> >         doc_type_table.c.doc_type=='widgets'))
>
> > join_table2 = get_join_table('spam')
> > stmt = stmt.join(join_table2,
> > SA.and_(doc_type_table.c.ref_id==join_table2.primary_key[0],
> >         doc_type_table.c.doc_type=='spam'))
>
> > stmt.execute()
>
> > I tried hacking with the _group_parenthesized attribute, but to no
> > avail on the parenthesis.
>
> > Any help would be appreciated.


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