Re: [SQLObject] .get(int) vs. .get(string)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Ian B. <ia...@co...> - 2004-03-27 04:59:12
|
On Mar 26, 2004, at 3:41 AM, Hendrik Mans wrote:
> Hello everyone,
>
> ---cut---
>>>> from Crop.Data.User import User
>>>> u1 = User.get(1)
>>>> u2 = User.get('1')
>>>> u1 == u2
> False
> ---cut---
>
> Is this by design? I was expecting SQLObject to either return the same
> object instance *or* raise an exception when passing the string.
Well... not design. I guess it's a known problem, though I had
forgotten about it for a while. If you do something like:
class User(SQLObject):
def _init(self, id, connection=None):
id = int(id)
return SQLObject._init(self, id, connection=connection)
I believe that should resolve it for you. Ultimately the id type
should become part of a column specifier, like other columns are
specified, but there's some other issues involved with that that I
haven't gotten around to.
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|