I have a db structure similar to the person/dog tables in section "6.21 One
to many relation." I try the inner join (second form, from the book):
1 >>> rows =
db(db.person).select(join=db.dog.on(db.person.id==db.dog.owner))
2 >>> for row in rows:
3 print row.person.name, 'has', row.dog.name
4 Alex has Skipper
5 Alex has Snoopy
6 Bob has Puppy
In my db the 'person' table is 'Meet', and 'dog' is 'Session'. Here's what
I used:
meetAndSession = db(db.Meet).select(join=db.Session.on(db.Meet.id ==
db.Session.Meet))
I get back the 'person' ('Meet') fields, but not the 'dog' ('Session')
fields. For the Meet.Session field I get back a Set object. Should I be
using that as the set of Session records associated with the Meet record.
(I tried to reference row.Meet.Session.id, but got told there was no such
field. I also tried row.Session.id and got told the same thing.) As the
example shows row.dog.name, shouldn't I have a row.Session.<fieldName>?
Here's what "db stats" tells me it used:
SELECT Meet.id, Meet.Meet_name, Meet.Start_date, Meet.End_date,
Meet.Is_championship FROM Meet JOIN Session ON (Meet.id = Session.Meet) WHERE
(Meet.id > 0);
Given that, of course I'm getting no 'dog' ('Session') fields. What am I
missing?
Thanks.
--