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 18:37:36
|
Hey Ian, thanks for your fast answer. I tried your fix, and with a small modification, it seems to fix my test. # Next two lines added dbName =3D sqlmeta.style.pythonAttrToDBColumn(columnDef.name) if dbName =3D=3D sqlmeta.idName: continue I had to change: 1. columnDef.dbName gives an AttributeError - since columnDef is IntCol) 2. also changed self.idName to sqlmeta.idName We'll keep on testing with this fix in tomorrow (it's nearing eight o'clock in Europe). You have some suites we can run to the fix does not break anything else? If everything works out fine, what would be the next step? Thanks a lot for the help. Vladimir On 11/9/05, Ian Bicking <ia...@co...> wrote: > Ian Bicking wrote: > > I'm guessing this is a bug in the MySQL fromDatabase code (or maybe all > > fromDatabase code), because it should recognize which column is the id > > based on idName. > > I'm guessing a good fix for this would be this version of > sqlobject.main.sqlmeta.addColumnsFromDatabase: > > def addColumnsFromDatabase(sqlmeta, connection=3DNone): > soClass =3D sqlmeta.soClass > conn =3D connection or soClass._connection > for columnDef in conn.columnsFromSchema(sqlmeta.table, soClass): > # Next two lines added > dbName =3D columnDef.dbName or > sqlmeta.style.pythonAttrToDBColumn(columnDef.name) > if dbName =3D=3D self.idName: > continue > if columnDef.name not in sqlmeta.columnDefinitions: > sqlmeta.addColumn(columnDef) > > I don't have time to test this now, though. > > -- > Ian Bicking / ia...@co... / http://blog.ianbicking.org > |