Re: [SQLObject] Handling relations with multiple keys
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-06-25 03:39:16
|
On Fri, 2003-06-20 at 18:22, Bruno Trevisan wrote: > Hi there > > Continuing my experiences on using SQLObject I fall in another question: > is it possible to have a object linked to some other using more than one > table attribute as foreignKey ? > > My problem is: I have a Product Class and this product has a SubFamily > object which defines some extra product properties to me. It happens > that to query products for its subfamily I have to do a comparsion using > 2 fields from the subfamily table (subfamilly_id and family_id). Using > the foreignKey Col Class atribute I'm able, AFAIK, to set only one > field, which in my case isn't enough to pick the unique subfamily > object. > > How to handle this ? I'm not entirely clear on your schema, but you probably should create the getter yourself, something like: def _get_subFamily(self): return SubFamily.selectBy(subfamilyID=self.subfamilyID, familyID=self.familyID)[0] Or something like that... along those lines at least. Ian |