mirror of
https://github.com/django/django.git
synced 2025-10-30 17:16:10 +00:00
Fixed #34466 -- Reallowed setting cursor_factory in DATABASES["options"] on PostgreSQL.
Regression in 09ffc5c121.
This commit is contained in:
committed by
Mariusz Felisiak
parent
9daf8b4109
commit
73cbb372ba
@@ -223,7 +223,13 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
|
||||
conn_params.pop("assume_role", None)
|
||||
conn_params.pop("isolation_level", None)
|
||||
conn_params.pop("server_side_binding", None)
|
||||
server_side_binding = conn_params.pop("server_side_binding", None)
|
||||
conn_params.setdefault(
|
||||
"cursor_factory",
|
||||
ServerBindingCursor
|
||||
if is_psycopg3 and server_side_binding is True
|
||||
else Cursor,
|
||||
)
|
||||
if settings_dict["USER"]:
|
||||
conn_params["user"] = settings_dict["USER"]
|
||||
if settings_dict["PASSWORD"]:
|
||||
@@ -269,20 +275,13 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
connection = self.Database.connect(**conn_params)
|
||||
if set_isolation_level:
|
||||
connection.isolation_level = self.isolation_level
|
||||
if is_psycopg3:
|
||||
connection.cursor_factory = (
|
||||
ServerBindingCursor
|
||||
if options.get("server_side_binding") is True
|
||||
else Cursor
|
||||
)
|
||||
else:
|
||||
if not is_psycopg3:
|
||||
# Register dummy loads() to avoid a round trip from psycopg2's
|
||||
# decode to json.dumps() to json.loads(), when using a custom
|
||||
# decoder in JSONField.
|
||||
psycopg2.extras.register_default_jsonb(
|
||||
conn_or_curs=connection, loads=lambda x: x
|
||||
)
|
||||
connection.cursor_factory = Cursor
|
||||
return connection
|
||||
|
||||
def ensure_timezone(self):
|
||||
|
||||
Reference in New Issue
Block a user