Hi,

I am using the patch below in my local version of SQLObject for
several month now.  I think I already proposed it some time ago.  It
allows me to use an application I wrote using the SQLite backend
unmodified also with the MySQL backend.  The SQLite backend of
SQLObject has no problem with handling unicode queries.  Without the
patch, unicode queries do not work using the MySQL backend.  IMO it
makes no sense to prevent unicode queries from working, since MySQLdb
supports unicode queries.  Even more, the current mysqlconnection.py
code explicitly converts to unicode, in case of self.need_unicode.
The problem with the current code is, that it also tries to perform
this conversion even when the query is already of type unicode.  The
patch below fixes this.

--- sqlobject_orig/mysql/mysqlconnection.py
+++ sqlobject/mysql/mysqlconnection.py
@@ -92,7 +92,7 @@
         # done by calling ping(True) on the connection.
         for count in range(3):
             try:
-                if self.need_unicode:
+                if self.need_unicode and not isinstance(query, unicode):
                     # For MysqlDB 1.2.1 and later, we go
                     # encoding->unicode->charset (in the mysql db)
                     myquery = unicode(query, self.encoding)

Kind regards,
Markus

-------------------------------------------------------------------------
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

Reply via email to