diff options
| author | Scott Macpherson <scott@zerosleeps.com> | 2023-04-13 21:07:32 +1000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-04-14 11:02:47 +0200 |
| commit | 090d5ccc6c59e4df491ec0599c569834bdcf1409 (patch) | |
| tree | 5a1f8fe31cdd75b30e31e564ffa9de0865390791 /django | |
| parent | cd464fbc3ab5c3eccd9d026607341bfe859f10aa (diff) | |
[4.2.x] Fixed #34486 -- Fixed DatabaseOperations.compose_sql() crash with no existing database connection on PostgreSQL.
Regression in 09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca.
Backport of 53aee470d5b35e2708864d5221d2b5655e10c091 from main
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/postgresql/psycopg_any.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/psycopg_any.py b/django/db/backends/postgresql/psycopg_any.py index 579104dead..1fe6b15caf 100644 --- a/django/db/backends/postgresql/psycopg_any.py +++ b/django/db/backends/postgresql/psycopg_any.py @@ -18,7 +18,8 @@ try: TSTZRANGE_OID = types["tstzrange"].oid def mogrify(sql, params, connection): - return ClientCursor(connection.connection).mogrify(sql, params) + with connection.cursor() as cursor: + return ClientCursor(cursor.connection).mogrify(sql, params) # Adapters. class BaseTzLoader(TimestamptzLoader): |
