From: Ian B. <ia...@co...> - 2004-12-29 17:11:23
|
Max Ischenko wrote: > getting and setting the value with unicode string works fine. I.e. both > user.email = u'something' > and > print user.email # -> u'something' > works fine. > > The problem is with the following code: > > dbusers = User.selectBy(isGuest=False, email=email) > n = dbusers.count() > > It yields an error: ... > File "D:\Python23\Lib\site-packages\sqlobject\dbconnection.py", line > 196, in _executeRetry > return cursor.execute(query) > TypeError: argument 1 must be str, not unicode > > > Guess this is because email has not been coerced from unicode string to > db encoding as being done by normal getters and setters. That is true. I'm not sure how to best resolve this. There were a couple ideas when unicode columns first came up. One was adding an encoding to converters.UnicodeConverter; really there should be *some* UnicodeConverter even in converters, and perhaps a default encoding (which might default to ASCII, which is implicitly the case now). Ideally, each column would do its own quoting, so that a UnicodeCol would know its own encoding. But while that would allow for a database with multiple encodings (or maybe multiple databases with multiple encodings), that might not be a common-enough use case. I want to get rid of .q entirely, and make columns descriptors with a __sqlrepr__ method; at that point it would be much easier to make this addition. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |