-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2914 MongoClient should raise an error when given multiple URIs #747
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the MongoClient docs to remove the parts about accepting multiple URIs.
doc/migrate-to-pymongo4.rst
Outdated
@@ -187,6 +187,12 @@ MongoClient cannot execute operations after ``close()`` | |||
after being closed. The previous behavior would simply reconnect. However, | |||
now you must create a new instance. | |||
|
|||
MongoClient raises exception when given more than 1 URI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 -> one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pymongo/mongo_client.py
Outdated
# Raise an error when we have more than one URI | ||
if len([i for i in host if "/" in i]) > 1: | ||
raise ConfigurationError("MongoClient() only accepts 1 URI at a " | ||
"time") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say: "host must not contain multiple MongoDB URIs"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pymongo/mongo_client.py
Outdated
@@ -645,6 +645,10 @@ def __init__( | |||
dbase = None | |||
opts = common._CaseInsensitiveDictionary() | |||
fqdn = None | |||
# Raise an error when we have more than one URI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is redundant because the error message says the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pymongo/mongo_client.py
Outdated
@@ -645,6 +645,10 @@ def __init__( | |||
dbase = None | |||
opts = common._CaseInsensitiveDictionary() | |||
fqdn = None | |||
# Raise an error when we have more than one URI | |||
if len([i for i in host if "/" in i]) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i->h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
username, and password present will be used. For username and | ||
a simple hostname. It can also be a list of hostnames but no more | ||
than one URI. Any port specified in the host string(s) will override | ||
the `port` parameter. For username and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make a similar change to the description in the :Parameters:
list below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.