From 18d79033b90902a6d6b615b42051191fd1b37892 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Mon, 26 Feb 2024 10:53:47 +0100 Subject: [PATCH] Refs #34200 -- Removed unnecessary check in DatabaseWrapper.ensure_role() on PostgreSQL. ensure_role() is only called in init_connection_state() where a new connection is established. --- django/db/backends/postgresql/base.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 96ba33a882..793a7bf3bc 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -296,8 +296,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): return False def ensure_role(self): - if self.connection is None: - return False if new_role := self.settings_dict["OPTIONS"].get("assume_role"): with self.connection.cursor() as cursor: sql = self.ops.compose_sql("SET ROLE %s", [new_role])