summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Macpherson <scott@zerosleeps.com>2023-04-13 21:07:32 +1000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-14 11:02:47 +0200
commit090d5ccc6c59e4df491ec0599c569834bdcf1409 (patch)
tree5a1f8fe31cdd75b30e31e564ffa9de0865390791 /tests
parentcd464fbc3ab5c3eccd9d026607341bfe859f10aa (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 'tests')
-rw-r--r--tests/backends/postgresql/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py
index 9c4512be24..947d51ea1e 100644
--- a/tests/backends/postgresql/tests.py
+++ b/tests/backends/postgresql/tests.py
@@ -420,3 +420,13 @@ class Tests(TestCase):
with self.assertRaisesMessage(NotSupportedError, msg):
connection.check_database_version_supported()
self.assertTrue(mocked_get_database_version.called)
+
+ def test_compose_sql_when_no_connection(self):
+ new_connection = connection.copy()
+ try:
+ self.assertEqual(
+ new_connection.ops.compose_sql("SELECT %s", ["test"]),
+ "SELECT 'test'",
+ )
+ finally:
+ new_connection.close()