-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
index_view::create_one() checks whether the server replies with a note indicating the index that the user tried to create already exists:
if (result_view["note"] && bsoncxx::string::to_string(result_view["note"].get_utf8().value) == "all indexes already exist") { return bsoncxx::stdx::nullopt; }
I assume the purpose is to signal to the user if they are trying to create an index that already exists.
But, similar to "ns not found" or other error message checks, I do not think we should rely on the exact value of the "note" string. If the server changes that note, the check will no longer be correct.
Furthermore, we may not need to check for index existence at all. The index management spec does not require we do. I do not know about every driver, but quickly checking pymongo shows that collection.create_index() always returns the index name, even if it exists.
- is related to
-
CXX-2089 Use server error codes in place of error messages when possible
- Closed