﻿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
31815	CheckConstraint() with unicode parameters crashes on PostgreSQL.	JSAustin	Mariusz Felisiak	"I am trying to create a model with a constraint on a field that uses UTF-8 encodings. Specifically, I'm trying to constrain scientific unit strings. The problematic one is: 'µg/mL'. The µ symbol has a b'\xc2\xb5' encoding with utf-8. When I add this as one of the check constraints, I get this error:

File ""D:\DjangoSite\venv\lib\site-packages\django\db\backends\postgresql\schema.py"", line 38, in quote_value
return psycopg2.extensions.adapt(value).getquoted().decode()
UnicodeEncodeError: 'latin-1' codec can't encode character '\u03bc' in position 0: ordinal not in range(256)

The migration is:
migrations.AddConstraint(model_name='biomarkertestinfo',constraint=models.CheckConstraint(check=models.Q(unit__in=['μg/mL', 'ng/mL', 'pg/mL', 'U/L', 'mIU/mL', 'kIU/mL']), name='constrained biomarker unit choices'),)

I am running PostgreSQL 12 locally for this with psycopg2 connection.

"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed	encoding utf-8	Simon Charette	Accepted	1	0	0	0	0	0
