From: Brad B. <br...@bb...> - 2003-07-24 18:05:47
|
On Thu, Jul 17, 2003 at 06:09:28PM +0200, Fran?ois Girault wrote: > Hi all, > > here's another feature I need for my project : I have several tables > whose primary key is composed of two or three columns. [snip] > As I want to do it clean, I think I'm going to realize a "Key" or "Id" object. > > This object would contain a list of Column objects, which together are > the primary key [snip] > I will start this soon, so I'd like to have some suggestions from > SQLObject's dev&users before diving in (Sorry for the delayed response. I briefly skimmed this before, and now that I know I need this, I'd like to contribute) I gather you've already implemented this. If so, how? There are various semantics that could be used. SQL style: class MonitoredDevice(SQLObject): """I'm a device being monitored.""" _cacheValues = False monitor = ForeignKey('Monitor') device = ForeignKey('Device') one_month_rate = CurrencyCol(notNone = True) expiration_date = DateTimeCol(notNone = True) ... primary_key(monitor, device) # or PrimaryKey(monitor, device) SQLObject style: class MonitoredDevice(SQLObject): """I'm a device being monitored.""" _cacheValues = False monitor = ForeignKey('Monitor') device = ForeignKey('Device') one_month_rate = CurrencyCol(notNone = True) expiration_date = DateTimeCol(notNone = True) ... _primary_key = (monitor, device) or maybe something else. In any case, these composite keys would supplant the autogenerated id column. Any other semantic ideas that I've missed? Is supplanting the autogenerated id column even possible in SQLObject without rewriting everything? -- Brad Bollenbach BBnet.ca |