Hi Daniel Hi Oleg, I don´t know how to realize this with union but i think this should do it
# plain sql would be sth like this (untested) select * from comment where (object='zoo' and object_id=?) or (object='cage' and object_id in (select id from cage where zoo=?)) or (object='animal' and object_id in (select id from animal where cage in (select id from cage where zoo=?))) # could be translated to python with sqlbuilder to sth like this (untested) from sqlobject.sqlbuilder import * aZoo = zoo.get(?) someAnimals = [animal.id for animal in aCage.animals for aCage in aZoo.cages] sql = SELECT(OR( AND(comment.q.object == 'zoo', comment.q.object_id == ? ), AND(comment.q.object == 'cage', IN(comment.q.object_id, aZoo.cages) ), AND(comment.q.object == 'animal', IN(comment.q.object_id, someAnimals)) )) result = comment._connection.queryAll(sql) didn´t test it but i think this should work? maybe the subselect for animals can be included into a single select select statement in sqlbuilder as well...? HTH, Frank On Thu, Mar 12, 2009 at 10:16, Oleg Broytmann <p...@phd.pp.ru> wrote: > On Wed, Mar 11, 2009 at 06:52:17PM -0700, Daniel Fetchinson wrote: >> Unfortunately I haven't found >> working examples of SQLBuilder + UNION constructions so far, if I >> don't manage to get it right I'll probably come back :) > > If you manage to get it right please come back anyway and show us an > example! :) > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ...@phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > sqlobject-discuss mailing list > sqlobject-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss