summaryrefslogtreecommitdiff
path: root/src/mongo/s/query/async_results_merger.cpp
diff options
context:
space:
mode:
authorJustin Seyster <justin.seyster@mongodb.com>2019-12-13 01:35:54 +0000
committerevergreen <evergreen@mongodb.com>2019-12-13 01:35:54 +0000
commit3a62fec23a50653994e01d1b1725d80a10fc208d (patch)
tree6eda6709522577d39a5d82a3afe25c7feb252e70 /src/mongo/s/query/async_results_merger.cpp
parent07ba9da4013e908e7a9e37c4a7f482eddd9c3edc (diff)
downloadmongo-3a62fec23a50653994e01d1b1725d80a10fc208d.tar.gz
SERVER-43669 Serialize "sortKey" as BSONArray
Diffstat (limited to 'src/mongo/s/query/async_results_merger.cpp')
-rw-r--r--src/mongo/s/query/async_results_merger.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index c94e309891c..bff8b0902aa 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -64,7 +64,11 @@ BSONObj extractSortKey(BSONObj obj, bool compareWholeSortKey) {
if (compareWholeSortKey) {
return key.wrap();
}
- invariant(key.type() == BSONType::Object);
+ // TODO (SERVER-43361): We expect the sort key to be an array, but if the sort key originated
+ // from a 4.2 mongod, it will be a document, instead. Either way, 'isABSONObj()' will return
+ // true, and 'compareSortKeys()' will behave the same way. After branching for 4.5, we can
+ // tighten this invariant to specifically require a 'BSONArray' type.
+ invariant(key.isABSONObj());
return key.Obj();
}
@@ -75,8 +79,8 @@ BSONObj extractSortKey(BSONObj obj, bool compareWholeSortKey) {
int compareSortKeys(BSONObj leftSortKey, BSONObj rightSortKey, BSONObj sortKeyPattern) {
// This does not need to sort with a collator, since mongod has already mapped strings to their
// ICU comparison keys as part of the $sortKey meta projection.
- const bool considerFieldName = false;
- return leftSortKey.woCompare(rightSortKey, sortKeyPattern, considerFieldName);
+ const BSONObj::ComparisonRulesSet rules = 0; // 'considerFieldNames' flag is not set.
+ return leftSortKey.woCompare(rightSortKey, sortKeyPattern, rules);
}
} // namespace
@@ -679,7 +683,7 @@ bool AsyncResultsMerger::_addBatchToBuffer(WithLock lk,
str::stream() << "Missing field '" << AsyncResultsMerger::kSortKeyField
<< "' in document: " << obj);
return false;
- } else if (!_params.getCompareWholeSortKey() && key.type() != BSONType::Object) {
+ } else if (!_params.getCompareWholeSortKey() && !key.isABSONObj()) {
remote.status =
Status(ErrorCodes::InternalError,
str::stream() << "Field '" << AsyncResultsMerger::kSortKeyField