[SQLObject] 'joins' using MultipleJoin
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Garrett S. <ga...@mo...> - 2006-02-05 04:09:13
|
The FAQ seems to suggest that a MultipleJoin attribute uses a single query = to retrieve related objects. So, the example provided in the FAQ: for contact in customer.contacts: print ' ', contact.phoneNumber results in a single query. (I'm assuming that 'contacts' is defined as a Mu= ltipleJoin attribute -- maybe this is wrong.) However, SQLObject will a) retrieve the IDs of the 'joined' table and b) ex= ecute a select for each ID. Yikes! There should be a huge disclaimer in the= docs, IMO, with this behavior. After replacing every instance of MultipleJoin with a comparable _get_foo m= ethod, this gross inefficiency goes away. E.g. rather than contacts =3D MultipleJoin('Contact', orderBy=3D'last_name') I use: _get_contacts(self): return Contact.selectBy(contactID=3Dself.id, orderBy=3DContact.q.last= Name) Is there some reason MultipleJoin isn't just a descriptor for a select? Garrett |