[SQLObject] Selecting child records using a sub-query
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Andy T. <an...@gm...> - 2005-05-12 10:56:20
|
Hi all, Excuse me being obtuse, but how do I select all of the child records for a specific parent in a 1:M foreign key relationship? E.g. given parent and child classes; class Parent(SQLObject): name =3D StringCol() children =3D MultipleJoin('Child') class Child(SQLObject): name =3D StringCol() parent =3D ForeignKey('Parent') How do I select all of the Child objects linked to the Parent with a name of 'Andy'? I've tried; >>> kids =3D Child.select(Parent.name =3D=3D 'Andy') and >>> kids =3D Child.select(Child.q.parent.name =3D=3D 'Andy') and various variations on that theme but haven't hit upon the one that works. Can anyone enlighten me. I'm using 0.6.1 if that makes any difference. Thanks in advance, Andy --=20 From the desk of Andrew J Todd esq |