Enh. request: more details on Unicode type warning

16 views
Skip to first unread message

werner

unread,
Sep 9, 2011, 11:01:43 AM9/9/11
to sqlal...@googlegroups.com
Tracking down where one forgot to use u'' e.g.:

somemodelinstance.somecol = 'somevalue'
instead of:
somemodelinstance.somecol = u'somevalue'

is sometimes not that easy to track down as the warning doesn't provide
any hints.

C:\python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engine\default.py:448:
SAWarning: Unicode type received non-unicode bind param value
param.append(processors[key](compiled_params[key]))

Tried to come up with a patch but can't figure out how/where this
warning is generated.

Could it include e.g. the model class and column name?

Werner

Michael Bayer

unread,
Sep 9, 2011, 11:07:13 AM9/9/11
to sqlal...@googlegroups.com


This warning is emitted by the datatype and has no awareness of the column to which it is attached (it could be associated with many) nor is the column in question passed in, nor is there even necessarily a column in use. The column itself then has no awareness of the ORM or any kind of model objects, etc.

To track the warning, have the warning raise an exception:

http://docs.python.org/library/warnings.html


werner

unread,
Sep 10, 2011, 4:05:35 AM9/10/11
to sqlal...@googlegroups.com
Thanks for the detailed explanation and the solution.

Werner

Reply all
Reply to author
Forward
0 new messages