sql: handle unicode elements in ranked-items and password fields (#6921)

This commit is contained in:
Frédéric Péters 2015-04-11 21:22:09 +02:00
parent 2d2e422e30
commit 2a792d23d7
1 changed files with 2 additions and 2 deletions

View File

@ -725,7 +725,7 @@ class SqlMixin(object):
if value is not None:
if field.key in ('ranked-items', 'password'):
# turn {'poire': 2, 'abricot': 1, 'pomme': 3} into an array
value = [[x, str(y)] for x, y in value.items()]
value = [[x, unicode(y).encode('utf-8')] for x, y in value.items()]
elif sql_type == 'varchar':
assert isinstance(value, basestring)
elif sql_type == 'date':
@ -757,7 +757,7 @@ class SqlMixin(object):
elif field.key == 'password':
d = {}
for fmt, val in value:
d[fmt] = val
d[fmt] = unicode(val, 'utf-8')
value = d
if sql_type == 'date':
value = value.timetuple()