Hi All, Found a bug using the SQLObject trunk from svn with MySQLdb 1.2.1 (the default on Ubuntu). Using the following table: CREATE TABLE `cron` ( `cron_id` int(11) NOT NULL auto_increment, `module` enum('Build','Doc','Test') NOT NULL, `args` varchar(256) NOT NULL, `time` time NOT NULL, `days_of_week` set('0','1','2','3','4','5','6') NOT NULL, PRIMARY KEY (`cron_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
Using the following SQLObject code: class Cron(SQLObject): class sqlmeta: fromDatabase = True idName = "cron_id" print Cron.sqlmeta.columns print Cron.get(1) I get the following: {'args': <SOStringCol args default=''>, 'daysOfWeek': <SOCol daysOfWeek default=''>, 'cronID': <SOIntCol cronID default=None>, 'module': <SOCol module default=''>, 'time': <SOCol time default=''>} Traceback (most recent call last): File "cron.py", line 41, in <module> print Cron.get(1) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/main.py", line 917, in get val._init(id, connection, selectResults) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/main.py", line 956, in _init selectResults = self._connection._SO_selectOne(self, dbNames) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/dbconnection.py", line 519, in _SO_selectOne return self._SO_selectOneAlt(so, columnNames, so.q.id==so.id) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/dbconnection.py", line 529, in _SO_selectOneAlt clause=condition))) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/dbconnection.py", line 385, in queryOne return self._runWithConnection(self._queryOne, s) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/dbconnection.py", line 255, in _runWithConnection val = meth(conn, *args) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/dbconnection.py", line 378, in _queryOne self._executeRetry(conn, c, s) File "/home/brianc/svn_knightly/trunk/backend/knightly/lib/sqlobject/mysql/mysqlconnection.py", line 114, in _executeRetry return cursor.execute(query) File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py", line 159, in execute self.errorhandler(self, TypeError, m) File "/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue TypeError: str() takes at most 1 argument (3 given) Upgrading to MySQLdb 1.2.2 yields the following correct output: {'args': <SOStringCol args default=''>, 'daysOfWeek': <SOCol daysOfWeek default=''>, 'cronID': <SOIntCol cronID default=None>, 'module': <SOCol module default=''>, 'time': <SOCol time default=''>} <Cron 1 cronID=1L module='Build' args='everything' time='datetime.timedelt...)' daysOfWeek='0,1,2'> I noticed there is other MySQLdb version specific stuff in mysqlconnection.py so maybe this should be added? Why do the ENUM, SET, and TIME field types get interpreted as SOCol's. Why not EnumCol, SetCol, and TimeCol? I can still access the data in them, but not as I first thought. SetCol returns a string that I have to then parse into a python set. And TimeCol comes out as a datetime.timedelta, this appears to be a resurfaced bug that was fixed in 0.7.2: "If the DB API driver returns timedelta instead of time (MySQLdb does this) it is converted to time; but if the timedelta has days an exception is raised." Thanks, Brian ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss