I'm looking at writing a TurboGears-based application where I'll have 
cause to use not only UNION but also INTERSECT and EXCEPT. The 
SQLAlchemy documentation appears to indicate that only UNION is supported.

Is there any chance of INTERSECT or EXCEPT showing up in future versions 
of SQLAlchemy? If a patch should be straightforward to write, I wouldn't 
mind trying my hand at one.


Also -- whereas with UNION alone there's little need to control nesting 
order, when one adds INTERSECT and EXCEPT in it can be important to 
specify that one wants (A UNION B) INTERSECT C as opposed to A UNION (B 
INTERSECT C); at least in PostgreSQL, INTERSECT binds tighter. I imagine 
that the natural syntax for combining UNIONs and INTERSECTs would be 
something like the following:

users.select(
   users.c.city == 'Austin'
).union(
   users.select(users.c.city == 'Houston')
).intersect(
   users.select(users.c.age < 17)
)

...however, I don't see a plain way to clarify whether the intersect or 
the union should happen first.



_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to