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