1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31815 -- Fixed schema value encoding on PostgreSQL.

This commit is contained in:
Mariusz Felisiak
2020-07-27 06:39:02 +02:00
committed by GitHub
parent c1f8d87bb0
commit f4e93919e4
3 changed files with 18 additions and 1 deletions

View File

@@ -38,8 +38,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
def quote_value(self, value):
if isinstance(value, str):
value = value.replace('%', '%%')
adapted = psycopg2.extensions.adapt(value)
if hasattr(adapted, 'encoding'):
adapted.encoding = 'utf8'
# getquoted() returns a quoted bytestring of the adapted value.
return psycopg2.extensions.adapt(value).getquoted().decode()
return adapted.getquoted().decode()
def _field_indexes_sql(self, model, field):
output = super()._field_indexes_sql(model, field)