Skip to content

Commit 211b631

Browse files
JaeHyuck Sajacobtylerwalls
authored andcommitted
Fixed #36822 -- Added parameter limit for PostgreSQL with server-side binding.
1 parent b98075d commit 211b631

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

django/db/backends/postgresql/features.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ def uses_server_side_binding(self):
151151
options = self.connection.settings_dict["OPTIONS"]
152152
return is_psycopg3 and options.get("server_side_binding") is True
153153

154+
@cached_property
155+
def max_query_params(self):
156+
if self.uses_server_side_binding:
157+
return 2**16 - 1
158+
return None
159+
154160
@cached_property
155161
def prohibits_null_characters_in_text_exception(self):
156162
if is_psycopg3:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
3+
from django.db import connection
4+
from django.test import TestCase
5+
6+
7+
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL tests")
8+
class FeaturesTests(TestCase):
9+
def test_max_query_params_respects_server_side_params(self):
10+
if connection.features.uses_server_side_binding:
11+
limit = 2**16 - 1
12+
else:
13+
limit = None
14+
self.assertEqual(connection.features.max_query_params, limit)

0 commit comments

Comments
 (0)