the UNION stuff in query() took awhile to get right and had a lot of bugs in 
the 0.5 days.  If you try 0.7, you'll get:

SELECT anon_1.type AS anon_1_type 
FROM (SELECT 'Phrase' AS type UNION SELECT 'Exact' AS type) AS anon_1

so old bug, either work with SQL expressions (i.e. tables, select(), etc.) and 
pass to session.execute(), or work on upgrading to a more recent SQLAlchemy.



On Dec 9, 2011, at 5:29 PM, Alex Parij wrote:

> Hi ,
> 
> I'm using SA 0.5.
> query1 = session.query(literal_column("'Phrase'").label('type')).filter(...)
> query2 = session.query(literal_column("'Exact'").label('type')).filter(...)
> 
> and then :
> query1.union(query2)
> gives me :
> 
> SELECT 'Phrase'  as type
> FROM (SELECT 'Phrase' as type FROM table1 WHERE ....
>               UNION 
>               SELECT 'Exact' as type FROM table1 WHERE ....
> ) AS anon_1
> 
> But I need :
> 
> SELECT type
> FROM (
>   SELECT  'Phrase' AS type  FROM table1  WHERE ...
>  UNION 
>    SELECT  'Exact' AS type  FROM table1 WHERE...
> )  AS anon_1
> 
> Any ideas how I can fix the outer select?
> 
> Thanks !
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/sqlalchemy/-/K4EEBKA4WvAJ.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to