Re: [SQLObject] a complex query question
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Daniel F. <fet...@go...> - 2009-03-12 01:52:31
|
>> class comment( SQLObject ): >> object_id = Int( ) # this is the 'id' of the object this comment >> is associated to >> object_ = StringCol( validator=OneOf( [ 'animal', 'cage', 'zoo' ] >> ) ) # type of object >> content = UnicodeCol( ) # the actual comment >> >> select all comments that belong either to this zoo instance or to >> any cage in this zoo or any animal that is in a cage in the zoo? > > With such a setup the only way I can see is to issue a complex UNION > query that unions 3 different queries - SELECT comments for zoo, cages and > animals. > UNION queries are, of course, impossible with SQLObject tables but > possible with SQLBuilder. Thanks Oleg, I'll look at SQLBuilder. 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 :) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |