diff --git a/django_mongodb_backend/utils.py b/django_mongodb_backend/utils.py index 194c4698c..ced60bc8e 100644 --- a/django_mongodb_backend/utils.py +++ b/django_mongodb_backend/utils.py @@ -28,7 +28,7 @@ def check_django_compatability(): ) -def parse_uri(uri, *, db_name=None, conn_max_age=0, test=None): +def parse_uri(uri, *, db_name=None, test=None): """ Convert the given uri into a dictionary suitable for Django's DATABASES setting. @@ -56,7 +56,6 @@ def parse_uri(uri, *, db_name=None, conn_max_age=0, test=None): "USER": uri.get("username"), "PASSWORD": uri.get("password"), "OPTIONS": uri.get("options"), - "CONN_MAX_AGE": conn_max_age, } if "authSource" not in settings_dict["OPTIONS"] and uri["database"]: settings_dict["OPTIONS"]["authSource"] = uri["database"] diff --git a/docs/source/ref/utils.rst b/docs/source/ref/utils.rst index a5fb8ff3e..a05ad8b70 100644 --- a/docs/source/ref/utils.rst +++ b/docs/source/ref/utils.rst @@ -12,7 +12,7 @@ following parts can be considered stable. ``parse_uri()`` =============== -.. function:: parse_uri(uri, db_name=None, conn_max_age=0, test=None) +.. function:: parse_uri(uri, db_name=None, test=None) Parses a MongoDB `connection string`_ into a dictionary suitable for Django's :setting:`DATABASES` setting. @@ -32,8 +32,6 @@ doesn't specify ``defaultauthdb``. You can use the parameters to customize the resulting :setting:`DATABASES` setting: -- Use ``conn_max_age`` to configure :ref:`persistent database connections - `. - Use ``test`` to provide a dictionary of settings for test databases in the format of :setting:`TEST `. diff --git a/docs/source/releases/5.2.x.rst b/docs/source/releases/5.2.x.rst index 9a31f3e74..bad12733e 100644 --- a/docs/source/releases/5.2.x.rst +++ b/docs/source/releases/5.2.x.rst @@ -27,6 +27,9 @@ Backwards incompatible changes ------------------------------ - The minimum supported version of ``pymongo`` is increased from 4.6 to 4.7. +- The ``conn_max_age`` parameter of + :func:`~django_mongodb_backend.utils.parse_uri` is removed because persistent + connections are now used by default. Bug fixes --------- diff --git a/tests/backend_/utils/test_parse_uri.py b/tests/backend_/utils/test_parse_uri.py index c2c015b41..3198a4630 100644 --- a/tests/backend_/utils/test_parse_uri.py +++ b/tests/backend_/utils/test_parse_uri.py @@ -82,10 +82,6 @@ def test_auth_source_in_query_string_overrides_defaultauthdb(self): self.assertEqual(settings_dict["NAME"], "db") self.assertEqual(settings_dict["OPTIONS"], {"authSource": "auth"}) - def test_conn_max_age(self): - settings_dict = parse_uri("mongodb://localhost/db", conn_max_age=600) - self.assertEqual(settings_dict["CONN_MAX_AGE"], 600) - def test_test_kwarg(self): settings_dict = parse_uri("mongodb://localhost/db", test={"NAME": "test_db"}) self.assertEqual(settings_dict["TEST"], {"NAME": "test_db"})