Re: [SQLObject] dependent relationships
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-07-15 02:23:37
|
On Mon, 2003-07-14 at 09:01, len...@xs... wrote: > Hello, > > I have three tables: RELATION, PERSON and COMPANY. RELATION has a > normal primary key that is autogenerated by SQLObject. PERSON and > COMPANY are dependent on RELATION, so there is a one-to-one > relationship from RELATION to PERSON/COMPANY, and the primary key of > PERSON/COMPANY is the same as the foreign key: RELATION_ID. > > I have not been able to model this into SQLObject. Is this possible at > all? (I am using SQLObject 0.4). I think that what I am looking for is > a 'do not create a primary key column but use _somecolumn_ as primary > key for this table' option. > > Thanks for any suggestions! You could try just setting _idName, like: class Person(SQLObject): _idName = 'relation_id' But I suspect you will have a problem with ID generation when creating new objects (since you don't want an automatic id, you want a specific id). Unfortunately there's not a good answer until I apply Francois's patches, so you'll probably run into problems (one of his changes is that you can specify the id explicitly when using new()). I saved the patch off the list: http://colorstudy.com/~ianb/so04-2.diff You might want to try it out for this. I'll probably change some details when I apply it (names and stuff), but that should only be trivial changes for you to make. Ian |