Re: [SQLObject] bug with sqlmeta.idName and non autoincrement primary keys?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Vladimir B. <vla...@gm...> - 2005-11-09 15:39:55
|
Hi Oleg, Thanks for the quick response. The failure that you have asked about seems to be caused by the value '0' (as string). This ends up as the default value for person_id column. 0 comes from the MySql - when you create a primary key id column without autoincrement, MySql puts the default to 0. Why the 0 becomes string suddenly we do not know. The other failure (The object Person by the ID 0 does not exist) seems to come from the fact that the SQLObject code works with 'id' instance variable which by default has value 0, although we specify personID=3D22. Somehow the matching between the id and personID does not happen. If you can advise on where to put some print statement, please do so, we don't know enough about the code to be able to judge. Best regards, Vladimir On 11/9/05, Oleg Broytmann <ph...@ma...> wrote: > On Wed, Nov 09, 2005 at 04:02:26PM +0100, Vladimir Blagojevic wrote: > > class Person(SQLObject): > > class sqlmeta: > > idName =3D 'person_id' > > table =3D 'person' > > fromDatabase =3D True > > > > Person(id=3D1, name=3D'Paul') > > > Traceback (most recent call last): > > File "test_person.py", line 23, in test_insert1 > > Person(id=3D1, name=3D'Paul') > > File "c:\dev\python24\lib\site-packages\sqlobject-0.7.0-py2.4.egg\sql= object\main.py", > > line 1187, in __init__ > > self._create(id, **kw) > > File "c:\dev\python24\lib\site-packages\sqlobject-0.7.0-py2.4.egg\sql= object\main.py", > > line 1212, in _create > > self.set(**kw) > > File "c:\dev\python24\lib\site-packages\sqlobject-0.7.0-py2.4.egg\sql= object\main.py", > > line 1071, in set > > kw[name] =3D dbValue =3D from_python(value, self._SO_validatorState= ) > > File "c:\dev\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sql= object\col.py", > > line 560, in from_python > > (self.name, type(value)), value, state) > > Invalid: expected an int in the IntCol 'personID', got <type 'str'> ins= tead > > Please investigate it further; find and report what is the value for > person_id before the exception; this is in main.py, method SQLObject.set(= ). > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |