Re: [SQLObject] Non-integer primary keys
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-09-08 03:09:40
|
On Sunday, September 7, 2003, at 09:34 PM, Edmund Lian wrote: > Ian Bicking wrote: > >> Changes to use non-integer primary keys have been made to CVS. > > Does this mean that MyObject(3) and MyObject(str(3)) no longer point > to different objects? Unfortunately no, id columns still are treated specially, and there's no type coercion (though type coercion for other columns is now supported). You could add something like: def _init(self, id, connection=None): id = str(id) # or int(id) SQLObject._init(self, id, connection) Eventually the id column will use the same definition as other columns (so you can do automatic CREATE TABLE), and it'll get type coercion at the same time. Easier to do would be to add something like: _idType = int def _init(self, id, connection=None): id = self._idType(id) ... And then subclasses override this. But I'll leave that for local modifications, since that's not an interface I want in the long term. Ian |