On Mon, Jul 21, 2008 at 05:31:24PM -0700, Ray Van Dolson wrote: > class SystemsInfo(SQLObject): > class sqlmeta: > fromDatabase = True > table = 'SystemsInfo' > idType = str > idName = 'SystemName' > lazyUpdate = True > > So, my "id" key has been changed to SystemName. In this particular > table, SystemName is the primary key and is not allowed to be NULL. > All other columns may be NULL. > > I just want to create a bare minimum row: > > item = SystemsInfo(SystemName='uniqenname') [skip] > assert id is not None > AssertionError
If idTYpe is not autoincrement (integer, actually) SQLObject expects 'id' in the list of passed columns: > item = SystemsInfo(id='uniqename'). [skip] > raise DatabaseError, "internal error: %s" % self.__source.errmsg() > pymssql.DatabaseError: internal error: SQL Server message 264, severity 16, > state 1, line 1: > Column name 'SystemName' appears more than once in the result column list. > DB-Lib error message 20018, severity 5: > General SQL Server error: Check messages from the SQL Server. > And sure, enough; when I turn on SQL debugging I see that the INSERT > query includes SystemName twice. Oops, seems like a bug. I think what caused the bug is using fromDatabase and idName simultaneously - SQLObject drew SystemName from the DB and added it because of the idName. To work around the bug avoid using fromDatabase - declare your columns explicitly. > In the first version, there is only > one occurence of SystemName, but it is not at the beginning of the > query SQLObject stores columns in dictionaries so the order (of keys) could be random. Do not rely on the order of columns in SO. > Maybe I can remove SystemName from the column list somehow and stick to > using it via the id parameter which maybe should map over > transparently? Columns are in SystemsInfo.sqlmeta object (see main.py), in .columns, .columnList, .columnDefinitions. Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss