Hi,
one issue remains: When doing a select() using LIKE (maybe with other
SQLBuilder objects too) with a unicode string, one gets a traceback,
because the type of the variable query in
myquery = unicode(query, self.encoding)
in mysqlconnection.py is <type 'unicode'> instead of <type 'str'>. So
either SQLBuilder has to be fixed to return <type 'str'> in all cases,
or the line
if self.need_unicode:
in mysqlconnection.py has to be changed into
if self.need_unicode and not isinstance(query, unicode):
The following example can be used to reproduce the problem:
# ---- 8< ----
from sqlobject import *
sqlhub.processConnection = connectionForURI(
'mysql://[EMAIL
PROTECTED]/test?use_unicode=1&charset=utf8&sqlobject_encoding=utf-8')
class Test(SQLObject):
name = UnicodeCol()
Test.dropTable(ifExists=True)
Test.createTable(ifNotExists=True)
# In HTML 4 this would be: ä ö ü €
name = u'\u00E4 \u00F6 \u00FC \u20AC '
Test(name=name)
print Test.get(1).name.encode('utf-8') # ok
print Test.select(LIKE(Test.q.name, name))[0].name.encode('utf-8') # traceback
# ---- 8< ----
The traceback reads:
Traceback (most recent call last):
File "test.py", line 17, in ?
print Test.select(LIKE(Test.q.name, name))[0].name.encode('utf-8')
# traceback
File
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\sresults.py",
line 149, in __getitem__
return list(self.clone(start=start, end=start+1))[0]
File
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\sresults.py",
line 155, in __iter__
return iter(list(self.lazyIter()))
File
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\sresults.py",
line 163, in lazyIter
return conn.iterSelect(self)
File
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\dbconnection.py",
line 365, in iterSelect
select, keepConnection=False)
File
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\dbconnection.py",
line 705, in __init__
self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
File
"c:\python24\lib\site-packages\sqlobject-0.7.1rc1-py2.4.egg\sqlobject\mysql\mysqlconnection.py",
line 80, in _executeRetry
myquery = unicode(query, self.encoding)
TypeError: decoding Unicode is not supported
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss