Re: [Modeling-users] Couple of questions...
Status: Abandoned
Brought to you by:
sbigaret
From: John L. <jo...@vi...> - 2004-04-20 18:57:27
|
Sender: John Lenton <jo...@ma...> On Tue, Apr 20, 2004 at 09:46:39AM -0700, Aaron Freeman wrote: > (1) Is there a debug flag somewhere that dump all SQL queries to the > console? >=20 > (2) How are nested joins accomplished? >=20 > For example, in the AuthorBooks schema, lets assume there is another table > called publisher that has a 1-M relationship with books, like so (sorry > about the formatting): >=20 > .........................................................................= ... > ............. > .+-----------+.(0,1)..............(0,*).+-------+.(0,*)..............(0,1= ).+ > .|..Writer...|<-author----------books->>|.Book..|<<-books-------publisher= ->| > .Publisher.|. > .|-----------|.(nullify)......(cascade).|-------|........................= ..| > .|.lastName..|..........................|.title.|........................= ..| > .bizName...|. > .|.firstName.|..........................|.price.|........................= ..| > .location..|. > .|.age.......|.(0,1)....................+-------+........................= ..+ > .|.birthday..|<-pygmalion--+.............................................= ... > ............. > .+-----------+.(nullify)...|.............................................= ... > ............. > =20 > .....|....................|..............................................= ... > ............ > ......+--------------------+.............................................= ... > ............. > .........................................................................= ... > ............. >=20 > How would I get writers by publisher? > > More specifically, is there an elegant way to do a nested join in a single > query, or do I just have to do a single writer-book join and then iterate > over the resultset for the second join? I don't think so. I'd do it with [ i.valueForKeyPath('books.author') for i in ec.fetch('Publisher') ] which is clean enough for me. I guess what you'd want is for valueForKeyPath to be callable on a class... :) --=20 John Lenton (jo...@vi...) -- Random fortune: Sobre toda cosa guardada guarda tu coraz=F3n, porque de =E9l emana la vida. -- Salom=F3n.=20 |