Skip to content

Commit 56fe609

Browse files
committed
Revert "fix name"
This reverts commit 1519e0f.
1 parent e526ab9 commit 56fe609

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

django_mongodb/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def parse_uri(uri, conn_max_age=0, conn_health_checks=False, test=None):
3434
uri = parse_uri_mongo(uri)
3535
host = None
3636
port = None
37-
name = uri["database"]
38-
3937
if uri["fqdn"] is not None:
4038
# If the fqdn is present, this is a SRV URI and the host is the fqdn.
4139
host = f"mongodb+srv://{uri['fqdn']}"
@@ -47,6 +45,7 @@ def parse_uri(uri, conn_max_age=0, conn_health_checks=False, test=None):
4745
host = ",".join([f"{host}:{port}" for host, port in nodelist])
4846
settings_dict = {
4947
"ENGINE": "django_mongodb",
48+
"NAME": uri["database"],
5049
"HOST": host,
5150
"PORT": port,
5251
"USER": uri.get("username"),
@@ -55,8 +54,6 @@ def parse_uri(uri, conn_max_age=0, conn_health_checks=False, test=None):
5554
"CONN_MAX_AGE": conn_max_age,
5655
"CONN_HEALTH_CHECKS": conn_health_checks,
5756
}
58-
if name:
59-
settings_dict["NAME"] = name
6057
if test:
6158
settings_dict["TEST"] = test
6259
return settings_dict

tests/utils_/test_parse_uri.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def test_simple_uri(self):
2525
def test_no_database(self):
2626
settings_dict = parse_uri("mongodb://cluster0.example.mongodb.net/")
2727
self.assertEqual(settings_dict["ENGINE"], "django_mongodb")
28+
self.assertIsNone(settings_dict["NAME"])
2829
self.assertEqual(settings_dict["HOST"], "cluster0.example.mongodb.net")
29-
self.assertFalse("NAME" in settings_dict)
3030

3131
@patch("dns.resolver.resolve")
3232
def test_srv_uri_with_options(self, mock_resolver):

0 commit comments

Comments
 (0)