﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3115	Postgresql backend should convert Unicode input to bytestrings	Manuel Saelices <msaelices@…>	Adrian Holovaty	"ORM fails in PostgreSQL when you filter with unicode strings. For example:

{{{

>>> from django.contrib.auth.models import User
>>> User.objects.filter(username=u'admin')
...
ProgrammingError: ERROR:  column ""admin"" does not exist

SELECT ""auth_user"".""id"",""auth_user"".""username"",""auth_user"".""first_name"",""auth_user"".""last_name"",""auth_user"".""email"",""auth_user"".""password"",""auth_user"".""is_staff"",""auth_user"".""is_active"",""auth_user"".""is_superuser"",""auth_user"".""last_login"",""auth_user"".""date_joined"" FROM ""auth_user"" WHERE (""auth_user"".""username"" = admin) ORDER BY ""auth_user"".""username"" ASC

}}}

The problem is on psycopg library, here are an example:

{{{
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute('SELECT * from auth_user WHERE username = %s', [u'admin'])
...
ProgrammingError: ERROR:  column ""admin"" does not exist

SELECT * from auth_user WHERE username = admin
}}}

Ok, it's true... it's not a django error, but for example, in newforms all is unicode... ¿what we do? ¿Use psycopg2? ¿convert all unicodes to ascii in lookups? ¿convert all params on postgresql?. Call is made on ''django/db/models/query.py'', on this sentences:

{{{
     cursor = connection.cursor()
     select, sql, params = self._get_sql_clause()
     cursor.execute(""SELECT "" + (self._distinct and ""DISTINCT "" or """") + "","".join(select) + sql, params)
}}}

"	defect	closed	Database layer (models, ORM)	dev	major	fixed			Unreviewed	0	0	0	0	0	0
