summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-16 10:22:02 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-17 08:24:08 +0100
commit0e2649fdf40cedc5be7e2c0e5f7711f315e36b84 (patch)
treee970a4cd9f3bd3d26f888c7c1342af753b440dcf /tests/backends
parentc8a76059ff6ff37fb51972fe2ba8b9d9464af769 (diff)
downloaddjango-0e2649fdf40cedc5be7e2c0e5f7711f315e36b84.tar.gz
Fixed #34255 -- Made PostgreSQL backend use client-side parameters binding with psycopg version 3.
Thanks Guillaume Andreu Sabater for the report. Co-authored-by: Florian Apolloner <apollo13@users.noreply.github.com>
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/postgresql/tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py
index 7b0e0bfb52..ab66e7ab0e 100644
--- a/tests/backends/postgresql/tests.py
+++ b/tests/backends/postgresql/tests.py
@@ -277,6 +277,25 @@ class Tests(TestCase):
finally:
new_connection.close()
+ @unittest.skipUnless(is_psycopg3, "psycopg3 specific test")
+ def test_connect_server_side_binding(self):
+ """
+ The server-side parameters binding role can be enabled with DATABASES
+ ["OPTIONS"]["server_side_binding"].
+ """
+ from django.db.backends.postgresql.base import ServerBindingCursor
+
+ new_connection = connection.copy()
+ new_connection.settings_dict["OPTIONS"]["server_side_binding"] = True
+ try:
+ new_connection.connect()
+ self.assertEqual(
+ new_connection.connection.cursor_factory,
+ ServerBindingCursor,
+ )
+ finally:
+ new_connection.close()
+
def test_connect_no_is_usable_checks(self):
new_connection = connection.copy()
try: