@@ -133,8 +133,7 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
133133
134134 break ;
135135 }
136- case IndexVersion::kV2 :
137- case IndexVersion::kV2Unique : {
136+ case IndexVersion::kV2 : {
138137 if (keyElement.isNumber ()) {
139138 double value = keyElement.number ();
140139 if (std::isnan (value)) {
@@ -220,7 +219,6 @@ StatusWith<BSONObj> validateIndexSpec(
220219 bool hasNamespaceField = false ;
221220 bool hasVersionField = false ;
222221 bool hasCollationField = false ;
223- bool isUniqueIndex = false ;
224222
225223 auto fieldNamesValidStatus = validateIndexSpecFieldNames (indexSpec);
226224 if (!fieldNamesValidStatus.isOK ()) {
@@ -365,13 +363,6 @@ StatusWith<BSONObj> validateIndexSpec(
365363 if (!statusWithMatcher.isOK ()) {
366364 return statusWithMatcher.getStatus ();
367365 }
368- } else if (IndexDescriptor::kUniqueFieldName == indexSpecElemFieldName) {
369- // Note: Here we only consider whether or not "unique" field is specified and that its
370- // value evaluates to true. "_id" index for instance is unique, but the index spec for
371- // it doesn't carry a "unique" field. "isUniqueIndex" being false for "_id" indexes is
372- // on purpose, and in future if we were to make "_id" index specs include
373- // "unique:true", then we would need to change the logic here to preserve its behavior.
374- isUniqueIndex = indexSpecElem.trueValue ();
375366 } else {
376367 // We can assume field name is valid at this point. Validation of fieldname is handled
377368 // prior to this in validateIndexSpecFieldNames().
@@ -380,8 +371,7 @@ StatusWith<BSONObj> validateIndexSpec(
380371 }
381372
382373 if (!resolvedIndexVersion) {
383- resolvedIndexVersion = IndexDescriptor::getDefaultIndexVersion (
384- featureCompatibility.getVersion (), isUniqueIndex);
374+ resolvedIndexVersion = IndexDescriptor::getDefaultIndexVersion ();
385375 }
386376
387377 if (!hasKeyPatternField) {
0 commit comments