Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-12 Thread Oleg Broytmann
On Fri, Jul 06, 2007 at 06:45:32PM -0300, Claudio Martinez wrote:
 Attached is a patch adding detection of ENUM and DOUBLE columns. It will
 also make sure that UnicodeCol is used instead of StringCol if use_unicode
 is on.
 
 The fix in col.py is there to allow notNone=False work on EnumCol because it
 will reject a None if it's not listed  in enumValues (MySQL doesn't add NULL
 to the list).

   Applied and committed in the revisions 2735-2739 (0.7, 0.8, 0.9
branches, the trunk and the docs). Thank you!

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-09 Thread Oleg Broytmann
On Fri, Jul 06, 2007 at 01:55:19PM -0600, Brian Cole wrote:
 Little confusing, which patch tracker to use?

   Whatever you prefer. If you have already registered at SF - you are
probably accustomed to the SF tracker; if you have used Trac before - use
Trac.

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


[SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-06 Thread Brian Cole
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


Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-06 Thread Oleg Broytmann
On Fri, Jul 06, 2007 at 10:25:04AM -0600, Brian Cole wrote:
 I noticed there is other MySQLdb version specific stuff in
 mysqlconnection.py so maybe this should be added?

   What should be added?

 Why do the ENUM, SET, and TIME field types get interpreted as SOCol's.

   Because nobody has committed a patch to parse the result of SHOW COLUMN
query. Wanna be the one? Extend sqlobject/mysql/mysqlconnection.py, method
.guessClass().

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-06 Thread Oleg Broytmann
On Fri, Jul 06, 2007 at 11:00:39AM -0600, Brian Cole wrote:
 Knew you would say that. =-)

   I don't even use MySQL, so who and how should fix bugs in
mysqlconnection? ;)

 Where/how do I submit patches?

http://sqlobject.org/community.html

   There is a Trac, there is a tracker at SourceForge, there is the mailing
list (for one-line fix).

PS. I am leaving the town for the weekend, will be completely offline for a
few days.

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-06 Thread Brian Cole
Knew you would say that. =-)

Where/how do I submit patches?

-Brian

On 7/6/07, Oleg Broytmann [EMAIL PROTECTED] wrote:
 On Fri, Jul 06, 2007 at 10:25:04AM -0600, Brian Cole wrote:
  I noticed there is other MySQLdb version specific stuff in
  mysqlconnection.py so maybe this should be added?

What should be added?

  Why do the ENUM, SET, and TIME field types get interpreted as SOCol's.

Because nobody has committed a patch to parse the result of SHOW COLUMN
 query. Wanna be the one? Extend sqlobject/mysql/mysqlconnection.py, method
 .guessClass().

 Oleg.
 --
  Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.

 -
 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


-
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


Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-06 Thread Brian Cole
Little confusing, which patch tracker to use?

http://sqlobject.org/community.html points to
http://sourceforge.net/tracker/?group_id=74338atid=540674

http://sqlobject.gcu.info/trac points to
http://sqlobject.gcu.info/trac/query?status=newstatus=assignedstatus=reopenedseverity=Patchesorder=priority

Luckily this is only a 2 line patch to fix TimeCol's in MySQL:
brianc$ svn diff
Index: mysql/mysqlconnection.py
===
--- mysql/mysqlconnection.py(revision 2730)
+++ mysql/mysqlconnection.py(working copy)
@@ -254,6 +254,8 @@
 return col.DateCol, {}
 elif t.startswith('timestamp'):
 return col.TimestampCol, {}
+elif t.startswith('time'):
+return col.TimeCol, {}
 elif t.startswith('bool'):
 return col.BoolCol, {}
 elif t.startswith('tinyblob'):

I'll probably have larger patches later. Which tracker should I use?

Thanks
-Brian

On 7/6/07, Oleg Broytmann [EMAIL PROTECTED] wrote:
 On Fri, Jul 06, 2007 at 11:00:39AM -0600, Brian Cole wrote:
  Knew you would say that. =-)

I don't even use MySQL, so who and how should fix bugs in
 mysqlconnection? ;)

  Where/how do I submit patches?

 http://sqlobject.org/community.html

There is a Trac, there is a tracker at SourceForge, there is the mailing
 list (for one-line fix).

 PS. I am leaving the town for the weekend, will be completely offline for a
 few days.

 Oleg.
 --
  Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.

 -
 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


-
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