mirror of
https://github.com/django/django.git
synced 2025-04-26 18:24:36 +00:00
Fixed #34470 -- Enforced UTF-8 encoding on PostgreSQL.
Regression in 6a2165816394ab4bb259f6171e82417e098e97a6.
This commit is contained in:
parent
73cbb372ba
commit
5b8a043bf5
@ -208,7 +208,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
self.ops.max_name_length(),
|
self.ops.max_name_length(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
conn_params = {"client_encoding": "UTF8"}
|
|
||||||
if settings_dict["NAME"]:
|
if settings_dict["NAME"]:
|
||||||
conn_params = {
|
conn_params = {
|
||||||
"dbname": settings_dict["NAME"],
|
"dbname": settings_dict["NAME"],
|
||||||
@ -220,6 +219,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
conn_params = {"dbname": "postgres", **settings_dict["OPTIONS"]}
|
conn_params = {"dbname": "postgres", **settings_dict["OPTIONS"]}
|
||||||
else:
|
else:
|
||||||
conn_params = {**settings_dict["OPTIONS"]}
|
conn_params = {**settings_dict["OPTIONS"]}
|
||||||
|
conn_params["client_encoding"] = "UTF8"
|
||||||
|
|
||||||
conn_params.pop("assume_role", None)
|
conn_params.pop("assume_role", None)
|
||||||
conn_params.pop("isolation_level", None)
|
conn_params.pop("isolation_level", None)
|
||||||
|
@ -22,3 +22,6 @@ Bugfixes
|
|||||||
* Reallowed, following a regression in Django 4.2, setting the
|
* Reallowed, following a regression in Django 4.2, setting the
|
||||||
``"cursor_factory"`` option in :setting:`OPTIONS` on PostgreSQL
|
``"cursor_factory"`` option in :setting:`OPTIONS` on PostgreSQL
|
||||||
(:ticket:`34466`).
|
(:ticket:`34466`).
|
||||||
|
|
||||||
|
* Enforced UTF-8 client encoding on PostgreSQL, following a regression in
|
||||||
|
Django 4.2 (:ticket:`34470`).
|
||||||
|
@ -323,6 +323,18 @@ class Tests(TestCase):
|
|||||||
finally:
|
finally:
|
||||||
new_connection.close()
|
new_connection.close()
|
||||||
|
|
||||||
|
def test_client_encoding_utf8_enforce(self):
|
||||||
|
new_connection = connection.copy()
|
||||||
|
new_connection.settings_dict["OPTIONS"]["client_encoding"] = "iso-8859-2"
|
||||||
|
try:
|
||||||
|
new_connection.connect()
|
||||||
|
if is_psycopg3:
|
||||||
|
self.assertEqual(new_connection.connection.info.encoding, "utf-8")
|
||||||
|
else:
|
||||||
|
self.assertEqual(new_connection.connection.encoding, "UTF8")
|
||||||
|
finally:
|
||||||
|
new_connection.close()
|
||||||
|
|
||||||
def _select(self, val):
|
def _select(self, val):
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
cursor.execute("SELECT %s::text[]", (val,))
|
cursor.execute("SELECT %s::text[]", (val,))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user