On Dec 11, 2003, at 5:26 PM, Ken Kinder wrote:
> I'm having a bit of confusion here. It seems that if you instanciate a
> SQLObject with a string, and another with an int, even of those are the
> same row, they are not evaluated as being the same object. Example
> code:
>
>>>> class MyClass(SQLObject):
> ... field = StringCol(length=20)
> ...
>>>> MyClass.createTable()
>>>> MyClass.new(field='spam')
> <MyClass 1 field='spam'>
>>>> MyClass.new(field='eggs')
> <MyClass 2 field='eggs'>
>>>> spam = MyClass(1)
>>>> spam2 = MyClass('1')
>>>> spam2 is spam
> False
>
> Shouldn't SQLObject know to cast the id to an int?
It could, except now you can have non-int IDs too, and we haven't added
a way to declare which one you are using.
Anyway, for the moment try:
class MyClass(SQLObject):
def _init(self, id, connection=None):
SQLObject._init(self, int(id), connection=connection)
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|