summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2015-06-18 16:33:54 -0400
committerRandolph Tan <randolph@10gen.com>2015-06-18 16:33:54 -0400
commitd7a19f4e49a93de40295d39c00abec96fdffe987 (patch)
treed6737214781a0555b09244d263999395910c3e78 /src/mongo
parentcffb338a1b4a07ce1c4207f7672dff589c607eee (diff)
downloadmongo-d7a19f4e49a93de40295d39c00abec96fdffe987.tar.gz
Revert "SERVER-18589 Create LiteParseQuery factory for find cmd"
This reverts commit cffb338a1b4a07ce1c4207f7672dff589c607eee.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/query/canonical_query.cpp48
-rw-r--r--src/mongo/db/query/canonical_query_test.cpp216
-rw-r--r--src/mongo/db/query/lite_parsed_query.cpp100
-rw-r--r--src/mongo/db/query/lite_parsed_query.h48
-rw-r--r--src/mongo/db/query/lite_parsed_query_test.cpp349
-rw-r--r--src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp2
6 files changed, 348 insertions, 415 deletions
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index 67f753e0591..4a68c34e7c5 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -244,18 +244,18 @@ namespace {
// 0, 0, 0 is 'ntoskip', 'ntoreturn', and 'queryoptions'
// false, false is 'snapshot' and 'explain'
- auto lpqStatus = LiteParsedQuery::makeAsOpQuery(baseQuery.ns(),
- 0,
- 0,
- 0,
- baseQuery.getParsed().getFilter(),
- baseQuery.getParsed().getProj(),
- baseQuery.getParsed().getSort(),
- emptyObj,
- emptyObj,
- emptyObj,
- false,
- false);
+ auto lpqStatus = LiteParsedQuery::make(baseQuery.ns(),
+ 0,
+ 0,
+ 0,
+ baseQuery.getParsed().getFilter(),
+ baseQuery.getParsed().getProj(),
+ baseQuery.getParsed().getSort(),
+ emptyObj,
+ emptyObj,
+ emptyObj,
+ false,
+ false);
if (!lpqStatus.isOK()) {
return lpqStatus.getStatus();
}
@@ -287,18 +287,18 @@ namespace {
// Pass empty sort and projection.
BSONObj emptyObj;
- auto lpqStatus = LiteParsedQuery::makeAsOpQuery(ns,
- skip,
- limit,
- 0,
- query,
- proj,
- sort,
- hint,
- minObj,
- maxObj,
- snapshot,
- explain);
+ auto lpqStatus = LiteParsedQuery::make(ns,
+ skip,
+ limit,
+ 0,
+ query,
+ proj,
+ sort,
+ hint,
+ minObj,
+ maxObj,
+ snapshot,
+ explain);
if (!lpqStatus.isOK()) {
return lpqStatus.getStatus();
}
diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp
index 14797c91ab3..d770fd33977 100644
--- a/src/mongo/db/query/canonical_query_test.cpp
+++ b/src/mongo/db/query/canonical_query_test.cpp
@@ -101,18 +101,18 @@ namespace {
// Passes in default values for LiteParsedQuery.
// Filter inside LiteParsedQuery is not used.
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Valid: regular TEXT.
ASSERT_OK(isValid("{$text: {$search: 's'}}", *lpq));
@@ -173,18 +173,18 @@ namespace {
// Passes in default values for LiteParsedQuery.
// Filter inside LiteParsedQuery is not used.
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Valid: regular GEO_NEAR.
ASSERT_OK(isValid("{a: {$near: [0, 0]}}", *lpq));
@@ -257,18 +257,18 @@ namespace {
// Passes in default values for LiteParsedQuery.
// Filter inside LiteParsedQuery is not used.
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Invalid: TEXT and GEO_NEAR.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}, a: {$near: [0, 0]}}", *lpq));
@@ -292,18 +292,18 @@ namespace {
// Filter inside LiteParsedQuery is not used.
BSONObj sort = fromjson("{$natural: 1}");
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- sort,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ sort,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Invalid: TEXT and {$natural: 1} sort order.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *lpq));
@@ -314,18 +314,18 @@ namespace {
// Filter inside LiteParsedQuery is not used.
BSONObj sort = fromjson("{$natural: -1}");
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- sort,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ sort,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Invalid: TEXT and {$natural: -1} sort order.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *lpq));
@@ -336,18 +336,18 @@ namespace {
// Filter inside LiteParsedQuery is not used.
BSONObj hint = fromjson("{a: 1}");
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- hint,
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ hint,
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Invalid: TEXT and {$natural: -1} sort order.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *lpq));
@@ -359,18 +359,18 @@ namespace {
// Filter inside LiteParsedQuery is not used.
BSONObj sort = fromjson("{$natural: 1}");
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- sort,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ sort,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Invalid: GEO_NEAR and {$natural: 1} sort order.
ASSERT_NOT_OK(isValid("{a: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}}}}",
@@ -383,18 +383,18 @@ namespace {
// Filter inside LiteParsedQuery is not used.
BSONObj hint = fromjson("{$natural: 1}");
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- hint,
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ hint,
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
// Invalid: GEO_NEAR and {$natural: 1} hint.
ASSERT_NOT_OK(isValid("{a: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}}}}",
@@ -406,18 +406,18 @@ namespace {
// Filter inside LiteParsedQuery is not used.
bool snapshot = true;
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery(ns,
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- snapshot,
- false))); // explain
+ assertGet(LiteParsedQuery::make(ns,
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ snapshot,
+ false))); // explain
// Invalid: TEXT and snapshot.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *lpq));
diff --git a/src/mongo/db/query/lite_parsed_query.cpp b/src/mongo/db/query/lite_parsed_query.cpp
index 64a48a33a03..c508d7d6565 100644
--- a/src/mongo/db/query/lite_parsed_query.cpp
+++ b/src/mongo/db/query/lite_parsed_query.cpp
@@ -371,9 +371,19 @@ namespace {
}
}
- pq->addMetaProjection();
+ // We might need to update the projection object with a $meta projection.
+ if (pq->returnKey()) {
+ pq->addReturnKeyMetaProj();
+ }
+ if (pq->showRecordId()) {
+ pq->addShowRecordIdMetaProj();
+ }
- Status validateStatus = pq->validateFindCmd();
+ if (pq->isAwaitData() && !pq->isTailable()) {
+ return Status(ErrorCodes::BadValue, "Cannot set awaitData without tailable");
+ }
+
+ Status validateStatus = pq->validate();
if (!validateStatus.isOK()) {
return validateStatus;
}
@@ -382,18 +392,36 @@ namespace {
}
// static
- StatusWith<unique_ptr<LiteParsedQuery>> LiteParsedQuery::makeAsOpQuery(const string& ns,
- int ntoskip,
- int ntoreturn,
- int queryOptions,
- const BSONObj& query,
- const BSONObj& proj,
- const BSONObj& sort,
- const BSONObj& hint,
- const BSONObj& minObj,
- const BSONObj& maxObj,
- bool snapshot,
- bool explain) {
+ StatusWith<unique_ptr<LiteParsedQuery>> LiteParsedQuery::make(const std::string& ns,
+ int ntoreturn,
+ const BSONObj& query) {
+ return make(ns,
+ 0, // ntoskip
+ ntoreturn,
+ 0, // query options
+ query,
+ BSONObj(), // proj
+ BSONObj(), // sort
+ BSONObj(), // hint
+ BSONObj(), // minObj
+ BSONObj(), // maxObj
+ false, // snapshot
+ false); // explain
+ }
+
+ // static
+ StatusWith<unique_ptr<LiteParsedQuery>> LiteParsedQuery::make(const string& ns,
+ int ntoskip,
+ int ntoreturn,
+ int queryOptions,
+ const BSONObj& query,
+ const BSONObj& proj,
+ const BSONObj& sort,
+ const BSONObj& hint,
+ const BSONObj& minObj,
+ const BSONObj& maxObj,
+ bool snapshot,
+ bool explain) {
unique_ptr<LiteParsedQuery> pq(new LiteParsedQuery());
pq->_sort = sort.getOwned();
pq->_hint = hint.getOwned();
@@ -410,31 +438,6 @@ namespace {
return std::move(pq);
}
- // static
- StatusWith<unique_ptr<LiteParsedQuery>> LiteParsedQuery::makeAsFindCmd(const std::string& ns,
- const BSONObj& query,
- int limit) {
- unique_ptr<LiteParsedQuery> pq(new LiteParsedQuery());
-
- pq->_ns = ns;
- pq->_filter = query.getOwned();
-
- if (limit <= 0) {
- return Status(ErrorCodes::BadValue, "limit value must be positive");
- }
-
- pq->_limit = limit;
-
- pq->addMetaProjection();
-
- Status validateStatus = pq->validateFindCmd();
- if (!validateStatus.isOK()) {
- return validateStatus;
- }
-
- return std::move(pq);
- }
-
BSONObj LiteParsedQuery::asFindCommand() const {
BSONObjBuilder bob;
@@ -935,23 +938,4 @@ namespace {
_partial = (options & QueryOption_PartialResults) != 0;
}
- void LiteParsedQuery::addMetaProjection() {
- // We might need to update the projection object with a $meta projection.
- if (returnKey()) {
- addReturnKeyMetaProj();
- }
-
- if (showRecordId()) {
- addShowRecordIdMetaProj();
- }
- }
-
- Status LiteParsedQuery::validateFindCmd() {
- if (isAwaitData() && !isTailable()) {
- return Status(ErrorCodes::BadValue, "Cannot set awaitData without tailable");
- }
-
- return validate();
- }
-
} // namespace mongo
diff --git a/src/mongo/db/query/lite_parsed_query.h b/src/mongo/db/query/lite_parsed_query.h
index 19fa8722af9..9623805d631 100644
--- a/src/mongo/db/query/lite_parsed_query.h
+++ b/src/mongo/db/query/lite_parsed_query.h
@@ -57,28 +57,24 @@ namespace mongo {
bool isExplain);
/**
- * Constructs a LiteParseQuery object as though it is from a legacy QueryMessage.
+ * Short and long forms for constructing a new LiteParsedQuery.
*/
- static StatusWith<std::unique_ptr<LiteParsedQuery>> makeAsOpQuery(const std::string& ns,
- int ntoskip,
- int ntoreturn,
- int queryoptions,
- const BSONObj& query,
- const BSONObj& proj,
- const BSONObj& sort,
- const BSONObj& hint,
- const BSONObj& minObj,
- const BSONObj& maxObj,
- bool snapshot,
- bool explain);
-
- /**
- * Constructs a LiteParseQuery object that can be used to serialize to find command
- * BSON object.
- */
- static StatusWith<std::unique_ptr<LiteParsedQuery>> makeAsFindCmd(const std::string& ns,
- const BSONObj& query,
- int limit);
+ static StatusWith<std::unique_ptr<LiteParsedQuery>> make(const std::string& ns,
+ int ntoreturn,
+ const BSONObj& query);
+
+ static StatusWith<std::unique_ptr<LiteParsedQuery>> make(const std::string& ns,
+ int ntoskip,
+ int ntoreturn,
+ int queryoptions,
+ const BSONObj& query,
+ const BSONObj& proj,
+ const BSONObj& sort,
+ const BSONObj& hint,
+ const BSONObj& minObj,
+ const BSONObj& maxObj,
+ bool snapshot,
+ bool explain);
/**
* Converts this LPQ into a find command.
@@ -223,16 +219,6 @@ namespace mongo {
*/
void initFromInt(int options);
- /**
- * Add the meta projection to this object if needed.
- */
- void addMetaProjection();
-
- /**
- * Returns OK if this is valid in the find command context.
- */
- Status validateFindCmd();
-
std::string _ns;
BSONObj _filter;
diff --git a/src/mongo/db/query/lite_parsed_query_test.cpp b/src/mongo/db/query/lite_parsed_query_test.cpp
index 4af9c8bc884..d31d0501b7e 100644
--- a/src/mongo/db/query/lite_parsed_query_test.cpp
+++ b/src/mongo/db/query/lite_parsed_query_test.cpp
@@ -42,69 +42,69 @@ namespace {
using unittest::assertGet;
TEST(LiteParsedQueryTest, InitSortOrder) {
- ASSERT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 1,
- 0,
- BSONObj(),
- BSONObj(),
- fromjson("{a: 1}"),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false) // explain
+ ASSERT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 1,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ fromjson("{a: 1}"),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false) // explain
.getStatus());
}
TEST(LiteParsedQueryTest, InitSortOrderString) {
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 1,
- 0,
- BSONObj(),
- BSONObj(),
- fromjson("{a: \"\"}"),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 1,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ fromjson("{a: \"\"}"),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false) // explain
.getStatus());
}
TEST(LiteParsedQueryTest, GetFilter) {
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery("testns",
- 5,
- 6,
- 9,
- BSON("x" << 5),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make("testns",
+ 5,
+ 6,
+ 9,
+ BSON("x" << 5),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
ASSERT_EQUALS(BSON("x" << 5 ), lpq->getFilter());
}
TEST(LiteParsedQueryTest, NumToReturn) {
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery("testns",
- 5,
- 6,
- 9,
- BSON("x" << 5),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make("testns",
+ 5,
+ 6,
+ 9,
+ BSON("x" << 5),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
ASSERT_EQUALS(6, lpq->getBatchSize());
ASSERT(lpq->wantMore());
@@ -112,68 +112,68 @@ namespace {
TEST(LiteParsedQueryTest, NumToReturnNegative) {
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery("testns",
- 5,
- -6,
- 9,
- BSON("x" << 5),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make("testns",
+ 5,
+ -6,
+ 9,
+ BSON("x" << 5),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
ASSERT_EQUALS(6, lpq->getBatchSize());
ASSERT(!lpq->wantMore());
}
TEST(LiteParsedQueryTest, MinFieldsNotPrefixOfMax) {
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- fromjson("{a: 1}"),
- fromjson("{b: 1}"),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ fromjson("{a: 1}"),
+ fromjson("{b: 1}"),
+ false, // snapshot
+ false) // explain
.getStatus());
}
TEST(LiteParsedQueryTest, MinFieldsMoreThanMax) {
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- fromjson("{a: 1, b: 1}"),
- fromjson("{a: 1}"),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ fromjson("{a: 1, b: 1}"),
+ fromjson("{a: 1}"),
+ false, // snapshot
+ false) // explain
.getStatus());
}
TEST(LiteParsedQueryTest, MinFieldsLessThanMax) {
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- fromjson("{a: 1}"),
- fromjson("{a: 1, b: 1}"),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ fromjson("{a: 1}"),
+ fromjson("{a: 1, b: 1}"),
+ false, // snapshot
+ false) // explain
.getStatus());
}
@@ -184,18 +184,18 @@ namespace {
const BSONObj& sort) {
unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- query,
- proj,
- sort,
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ query,
+ proj,
+ sort,
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
}
//
@@ -213,18 +213,18 @@ namespace {
}
TEST(LiteParsedQueryTest, ForbidNonMetaSortOnFieldWithMetaProject) {
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- BSONObj(),
- fromjson("{a: {$meta: \"textScore\"}}"),
- fromjson("{a: 1}"),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ fromjson("{a: {$meta: \"textScore\"}}"),
+ fromjson("{a: 1}"),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false) // explain
.getStatus());
assertLiteParsedQuerySuccess(BSONObj(),
@@ -233,72 +233,35 @@ namespace {
}
TEST(LiteParsedQueryTest, ForbidMetaSortOnFieldWithoutMetaProject) {
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- BSONObj(),
- fromjson("{a: 1}"),
- fromjson("{a: {$meta: \"textScore\"}}"),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ fromjson("{a: 1}"),
+ fromjson("{a: {$meta: \"textScore\"}}"),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false) // explain
.getStatus());
- ASSERT_NOT_OK(LiteParsedQuery::makeAsOpQuery("testns",
- 0,
- 0,
- 0,
- BSONObj(),
- fromjson("{b: 1}"),
- fromjson("{a: {$meta: \"textScore\"}}"),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false) // explain
+ ASSERT_NOT_OK(LiteParsedQuery::make("testns",
+ 0,
+ 0,
+ 0,
+ BSONObj(),
+ fromjson("{b: 1}"),
+ fromjson("{a: {$meta: \"textScore\"}}"),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false) // explain
.getStatus());
}
- TEST(LiteParsedQueryTest, MakeFindCmd) {
- auto result = LiteParsedQuery::makeAsFindCmd("testns", BSON("x" << 1), 2);
- ASSERT_OK(result.getStatus());
-
- auto&& lpq = result.getValue();
- ASSERT_EQUALS("testns", lpq->ns());
- ASSERT_EQUALS(BSON("x" << 1), lpq->getFilter());
- ASSERT_EQUALS(2, lpq->getLimit());
-
- ASSERT_EQUALS(BSONObj(), lpq->getProj());
- ASSERT_EQUALS(BSONObj(), lpq->getSort());
- ASSERT_EQUALS(BSONObj(), lpq->getHint());
- ASSERT_EQUALS(BSONObj(), lpq->getMin());
- ASSERT_EQUALS(BSONObj(), lpq->getMax());
-
- ASSERT_EQUALS(0, lpq->getSkip());
- ASSERT_EQUALS(0, lpq->getMaxScan());
- ASSERT_EQUALS(0, lpq->getMaxTimeMS());
- ASSERT_EQUALS(0, lpq->getOptions());
-
- ASSERT_FALSE(lpq->getBatchSize());
-
- ASSERT_FALSE(lpq->fromFindCommand());
- ASSERT_FALSE(lpq->isExplain());
- ASSERT_FALSE(lpq->returnKey());
- ASSERT_FALSE(lpq->showRecordId());
- ASSERT_FALSE(lpq->isSnapshot());
- ASSERT_FALSE(lpq->hasReadPref());
- ASSERT_FALSE(lpq->isTailable());
- ASSERT_FALSE(lpq->isSlaveOk());
- ASSERT_FALSE(lpq->isOplogReplay());
- ASSERT_FALSE(lpq->isNoCursorTimeout());
- ASSERT_FALSE(lpq->isAwaitData());
- ASSERT_FALSE(lpq->isExhaust());
- ASSERT_FALSE(lpq->isPartial());
- }
-
//
// Text meta BSON element validation
//
@@ -786,18 +749,18 @@ namespace {
TEST(LiteParsedQueryTest, ParseCommandNotFromFindCommand) {
std::unique_ptr<LiteParsedQuery> lpq(
- assertGet(LiteParsedQuery::makeAsOpQuery("testns",
- 5,
- 6,
- 9,
- BSON( "x" << 5 ),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- BSONObj(),
- false, // snapshot
- false))); // explain
+ assertGet(LiteParsedQuery::make("testns",
+ 5,
+ 6,
+ 9,
+ BSON( "x" << 5 ),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ BSONObj(),
+ false, // snapshot
+ false))); // explain
ASSERT(!lpq->fromFindCommand());
}
diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp
index df265bf170f..6e26b0bc061 100644
--- a/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp
+++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp
@@ -456,7 +456,7 @@ namespace {
};
unique_ptr<LiteParsedQuery> findCmd(
- fassertStatusOK(28688, LiteParsedQuery::makeAsFindCmd(nss.toString(), query, limit)));
+ fassertStatusOK(28688, LiteParsedQuery::make(nss.toString(), limit, query)));
QueryFetcher fetcher(grid.shardRegistry()->getExecutor(),
host,