Deepwalker/aldjemy — Issue #1: unicode issue?
Author: slafs
Created: 2012-02-11 19:40:05+00:00
State: open

Hi there! I think there's an issue with TextFields and unicode data.

Lets say i have a model

class M(models.Model):
a = models.CharField(max_length="200")
b = models.TextField()

and make a model instance:

>>> M.objects.create(a=u"aaaa", b=u"ń") # polish sign ("n" with a comma above)
>>> M.sa.query().all()

I get an error

Traceback (most recent call last):
File "", line 1, in
File "/home/slafs/.virtualenvs/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 1983, in all
return list(self)
File "/home/slafs/.virtualenvs/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2214, in instances
rows = [process[0](row, None) for row in fetch]
File "/home/slafs/.virtualenvs/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 2718, in _instance
populate_state(state, dict_, row, isnew, only_load_props)
File "/home/slafs/.virtualenvs/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 2572, in populate_state
populator(state, dict_, row)
File "/home/slafs/.virtualenvs/venv/local/lib/python2.7/site-packages/sqlalchemy/orm/strategies.py", line 150, in fetch_col
dict_[key] = row[col]
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0144' in position 0: ordinal not in range(128)

Just starting with SQLAlchemy so don't have a clue what's the deal with this for now. Test it with postgres and sqlite