summaryrefslogtreecommitdiff
path: root/src/mongo/db/index_names.cpp
diff options
context:
space:
mode:
authorsamontea <merciers.merciers@gmail.com>2018-06-13 10:40:11 -0400
committersamontea <merciers.merciers@gmail.com>2018-06-21 15:12:43 -0400
commit9a4c1c4cdde2829ded5eddd3a99fbe5d1d4c70cd (patch)
tree90aa9778e3f75336319e29457738718b49864075 /src/mongo/db/index_names.cpp
parent05e9267ef41f99cf61cdf1e745810580846e567f (diff)
downloadmongo-9a4c1c4cdde2829ded5eddd3a99fbe5d1d4c70cd.tar.gz
SERVER-35324 parse and store allPaths index spec
Diffstat (limited to 'src/mongo/db/index_names.cpp')
-rw-r--r--src/mongo/db/index_names.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/db/index_names.cpp b/src/mongo/db/index_names.cpp
index ce55d302f33..557a7c636bb 100644
--- a/src/mongo/db/index_names.cpp
+++ b/src/mongo/db/index_names.cpp
@@ -28,6 +28,7 @@
#include "mongo/db/index_names.h"
+#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/jsobj.h"
namespace mongo {
@@ -40,17 +41,21 @@ const string IndexNames::GEO_2DSPHERE = "2dsphere";
const string IndexNames::TEXT = "text";
const string IndexNames::HASHED = "hashed";
const string IndexNames::BTREE = "";
+const string IndexNames::ALLPATHS = "allPaths";
// static
string IndexNames::findPluginName(const BSONObj& keyPattern) {
BSONObjIterator i(keyPattern);
-
while (i.more()) {
BSONElement e = i.next();
- if (String != e.type()) {
+ string fieldName(e.fieldName());
+ if (String == e.type()) {
+ return e.String();
+ } else if ((fieldName == "$**") ||
+ (fieldName.size() > 4 && fieldName.substr(e.fieldNameSize() - 5) == ".$**")) {
+ return IndexNames::ALLPATHS;
+ } else
continue;
- }
- return e.String();
}
return IndexNames::BTREE;
@@ -66,7 +71,8 @@ bool IndexNames::existedBefore24(const string& name) {
bool IndexNames::isKnownName(const string& name) {
return name == IndexNames::GEO_2D || name == IndexNames::GEO_2DSPHERE ||
name == IndexNames::GEO_HAYSTACK || name == IndexNames::TEXT ||
- name == IndexNames::HASHED || name == IndexNames::BTREE;
+ name == IndexNames::HASHED || name == IndexNames::BTREE ||
+ (getTestCommandsEnabled() && name == IndexNames::ALLPATHS);
}
// static