diff options
| author | Raoni Timo <raoni@relume.io> | 2026-04-30 10:57:27 -0300 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-30 19:52:11 -0400 |
| commit | 9f790ef1a0f356cf6342b5d57bbaeac35aed0d9f (patch) | |
| tree | 1e14aebd1bce0831ca9353be104a219d430f71fd /django | |
| parent | 8726605e2d48fd733ae224344a11cc2163012f2d (diff) | |
Setting "check" in OPTIONS["pool"] previously raised TypeError because the
PostgreSQL backend always passed check= to ConnectionPool() and unpacked
**pool_options on top, regardless of CONN_HEALTH_CHECKS. The user's callable
now takes precedence via setdefault(); pool_options is copied first to avoid
mutating the user's settings dict.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/postgresql/base.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 42b37ab3c2..16cf7f84e6 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -216,11 +216,15 @@ class DatabaseWrapper(BaseDatabaseWrapper): # Ensure we run in autocommit, Django properly sets it later on. connect_kwargs["autocommit"] = True enable_checks = self.settings_dict["CONN_HEALTH_CHECKS"] + # Copy to avoid mutating the user's settings dict. + pool_options = {**pool_options} + pool_options.setdefault( + "check", ConnectionPool.check_connection if enable_checks else None + ) pool = ConnectionPool( kwargs=connect_kwargs, open=False, # Do not open the pool during startup. configure=self._configure_connection, - check=ConnectionPool.check_connection if enable_checks else None, **pool_options, ) # setdefault() ensures that multiple threads don't set this in |
