Please note: this project is inactive since early 2006

 
4.5.6 Dotted notation

Last, it is possible to qualify the fetched objects, not only on their own attributes, but also on their related objects' properties as well. The notation is the classical dotted notation, so, in order to fetch the Book objects written by authors having a pygmalion whose last name begins with the letter 'R' (whew!), you simply write:

objects=ec.fetch('Book', qualifier='author.pygmalion.lastName ilike "r*"')

which is really much simpler to write python than to explain in english!

For the curious, this will trigger a SQL method like:

SELECT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE 
FROM BOOK t0 
  INNER JOIN  (WRITER t1 
               INNER JOIN WRITER t2
               ON t1.FK_WRITER_ID=t2.ID )
  ON t0.FK_WRITER_ID=t1.ID
WHERE UPPER(t2.LAST_NAME) LIKE UPPER('r%')

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted by:SourceForge.net Logo