PYTHON-3657 Allow index name explicitly set to None (#1182)
Co-authored-by: Michael Pacheco <michael.dias@luizalabs.com>
This commit is contained in:
parent
acc6605ea1
commit
3077bbf1f9
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@ pymongo.egg-info/
|
||||
mongocryptd.pid
|
||||
.idea/
|
||||
.nova/
|
||||
venv/
|
||||
|
||||
@ -494,7 +494,7 @@ class IndexModel(object):
|
||||
.. _wildcard index: https://mongodb.com/docs/master/core/index-wildcard/
|
||||
"""
|
||||
keys = _index_list(keys)
|
||||
if "name" not in kwargs:
|
||||
if kwargs.get("name") is None:
|
||||
kwargs["name"] = _gen_index_name(keys)
|
||||
kwargs["key"] = _index_document(keys)
|
||||
collation = validate_collation_or_none(kwargs.pop("collation", None))
|
||||
|
||||
@ -307,6 +307,10 @@ class TestCollection(IntegrationTest):
|
||||
db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)])
|
||||
self.assertTrue("hello_-1_world_1" in db.test.index_information())
|
||||
|
||||
db.test.drop_indexes()
|
||||
db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], name=None)
|
||||
self.assertTrue("hello_-1_world_1" in db.test.index_information())
|
||||
|
||||
db.test.drop()
|
||||
db.test.insert_one({"a": 1})
|
||||
db.test.insert_one({"a": 1})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user