Bugs item #1094171, was opened at 2005-01-01 22:59
Message generated for change (Settings changed) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1094171&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: SQLObject from repository
>Status: Closed
>Resolution: Out of Date
Priority: 5
Private: No
Submitted By: Wichert Akkerman (wichert)
Assigned to: Oleg Broytmann (phd)
Summary: unicode queries break
Initial Comment:
When trying to store unicode data in a database I get
an exception with the backtrace below. Tested using
current SVN trunk.
File "./parse", line 10, in StoreChannels
nc[xid]=tvguide.database.Channel.byXid(xid)
File "<string>", line 1, in <lambda>
File
"/usr/local/lib/python2.3/site-packages/sqlobject/main.py",
line 961, in
_SO_fetchAlternateID
value)
File
"/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py",
line 400, in _SO_selectOneAlt
return self.queryOne("SELECT %s FROM %s WHERE %s =
%s" %
File
"/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py",
line 230, in queryOne
return self._runWithConnection(self._queryOne, s)
File
"/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py",
line 125, in _runWithConnection
val = meth(conn, *args)
File
"/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py",
line 223, in _queryOne
self._executeRetry(conn, c, s)
File
"/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py",
line 196, in _executeRetry
return cursor.execute(query)
TypeError: argument 1 must be str, not unicode
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2006-01-12 15:57
Message:
Logged In: YES
user_id=4799
Call me stupid, but I see
xid = sqlobject.StringCol(length=32, varchar=True,
alternateID=True)
xid *IS* StringCol in my eyes! Are my eyes lying?
Well, it is a known problem in SQLObject: if you do
.select(), .selectBy() or .by*() you have to convert unicode
to string yourself:
Channel.byXid(xid.encode(dbEncoding))
even for UnicodeColumns.
----------------------------------------------------------------------
Comment By: Wichert Akkerman (wichert)
Date: 2006-01-12 15:24
Message:
Logged In: YES
user_id=15420
This code did use a UnicodeCol. The class definition used is:
class Channel(sqlobject.SQLObject):
xid = sqlobject.StringCol(length=32, varchar=True,
alternateID=True)
name = sqlobject.UnicodeCol(length=64, varchar=True,
notNone=True)
programs = sqlobject.MultipleJoin("Program")
xid is not StringCol here, which is correct it is only
allowed to store ASCII data.
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2005-06-17 15:18
Message:
Logged In: YES
user_id=4799
Use UnicodeCol to convert unicode to DB strings.
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2005-03-01 18:12
Message:
Logged In: YES
user_id=4799
What type is xid column? Can you provide a test program?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1094171&group_id=74338
|