Skip to content

PYTHON-2295 MongoClient with multiple hosts directConnection=True should raise an error #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

prashantmital
Copy link
Contributor

No description provided.

@prashantmital prashantmital marked this pull request as draft June 26, 2020 04:31
@@ -624,7 +624,7 @@ def __init__(
username = None
password = None
dbase = None
opts = {}
opts = common._CaseInsensitiveDictionary()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? We already seem to use _CaseInsensitiveDictionary for keyword_opts down on line 663.

for h, p in nodes:
hosts.append("%s:%s" % (h, p))
with self.assertRaises(ConfigurationError):
MongoClient(hosts, directConnection=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use multiple hosts without caring whether they exist or not (since we'll raise an error before attempting to connect). So we could reduce this to:

            with self.assertRaises(ConfigurationError):
                MongoClient(['host1', 'host2'], directConnection=True)

@prashantmital prashantmital marked this pull request as ready for review June 30, 2020 03:06
@prashantmital prashantmital merged commit 0b375a2 into mongodb:master Jul 1, 2020
@prashantmital prashantmital deleted the PYTHON-2295/fix-directConnection-behavior branch July 1, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants