summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/base/string_data_comparator_interface.h2
-rw-r--r--src/mongo/bson/bsonelement.cpp4
-rw-r--r--src/mongo/bson/bsonelement.h4
-rw-r--r--src/mongo/bson/bsonmisc.h8
-rw-r--r--src/mongo/bson/bsonobj.cpp4
-rw-r--r--src/mongo/bson/bsonobj.h4
-rw-r--r--src/mongo/bson/mutable/const_element-inl.h21
-rw-r--r--src/mongo/bson/mutable/const_element.h25
-rw-r--r--src/mongo/bson/mutable/document-inl.h4
-rw-r--r--src/mongo/bson/mutable/document.cpp6
-rw-r--r--src/mongo/bson/mutable/document.h9
-rw-r--r--src/mongo/bson/mutable/element.h6
-rw-r--r--src/mongo/db/catalog/collection.cpp2
-rw-r--r--src/mongo/db/catalog/collection.h2
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.h2
-rw-r--r--src/mongo/db/clientlistplugin.cpp2
-rw-r--r--src/mongo/db/commands/current_op.cpp2
-rw-r--r--src/mongo/db/commands/list_collections.cpp2
-rw-r--r--src/mongo/db/exec/ensure_sorted.cpp2
-rw-r--r--src/mongo/db/exec/ensure_sorted.h4
-rw-r--r--src/mongo/db/exec/geo_near.cpp2
-rw-r--r--src/mongo/db/exec/merge_sort.h8
-rw-r--r--src/mongo/db/exec/projection.h2
-rw-r--r--src/mongo/db/exec/projection_exec.cpp2
-rw-r--r--src/mongo/db/exec/projection_exec.h4
-rw-r--r--src/mongo/db/exec/projection_exec_test.cpp4
-rw-r--r--src/mongo/db/exec/sort.cpp2
-rw-r--r--src/mongo/db/exec/sort.h8
-rw-r--r--src/mongo/db/exec/stagedebug_cmd.cpp2
-rw-r--r--src/mongo/db/index/btree_key_generator.cpp2
-rw-r--r--src/mongo/db/index/btree_key_generator.h4
-rw-r--r--src/mongo/db/index/btree_key_generator_test.cpp2
-rw-r--r--src/mongo/db/index/expression_keys_private.cpp10
-rw-r--r--src/mongo/db/index/expression_keys_private.h2
-rw-r--r--src/mongo/db/index/expression_params.cpp2
-rw-r--r--src/mongo/db/index/expression_params.h2
-rw-r--r--src/mongo/db/index/hash_access_method.h2
-rw-r--r--src/mongo/db/index/s2_access_method.h2
-rw-r--r--src/mongo/db/index/s2_common.h2
-rw-r--r--src/mongo/db/index/s2_key_generator_test.cpp4
-rw-r--r--src/mongo/db/matcher/expression_algo_test.cpp36
-rw-r--r--src/mongo/db/matcher/expression_array_test.cpp30
-rw-r--r--src/mongo/db/matcher/expression_leaf.cpp2
-rw-r--r--src/mongo/db/matcher/expression_leaf.h30
-rw-r--r--src/mongo/db/matcher/expression_leaf_test.cpp136
-rw-r--r--src/mongo/db/matcher/expression_parser.cpp2
-rw-r--r--src/mongo/db/matcher/expression_parser.h7
-rw-r--r--src/mongo/db/matcher/expression_parser_array_test.cpp80
-rw-r--r--src/mongo/db/matcher/expression_parser_geo_test.cpp50
-rw-r--r--src/mongo/db/matcher/expression_parser_leaf_test.cpp142
-rw-r--r--src/mongo/db/matcher/expression_parser_test.cpp8
-rw-r--r--src/mongo/db/matcher/expression_parser_tree_test.cpp20
-rw-r--r--src/mongo/db/matcher/expression_serialization_test.cpp106
-rw-r--r--src/mongo/db/matcher/expression_test.cpp10
-rw-r--r--src/mongo/db/matcher/expression_tree_test.cpp44
-rw-r--r--src/mongo/db/matcher/matcher.cpp2
-rw-r--r--src/mongo/db/matcher/matcher.h2
-rw-r--r--src/mongo/db/ops/modifier_interface.h8
-rw-r--r--src/mongo/db/ops/modifier_pull.h2
-rw-r--r--src/mongo/db/ops/modifier_pull_test.cpp2
-rw-r--r--src/mongo/db/ops/path_support_test.cpp2
-rw-r--r--src/mongo/db/query/canonical_query_test.cpp2
-rw-r--r--src/mongo/db/query/collation/collation_index_key.cpp5
-rw-r--r--src/mongo/db/query/collation/collation_index_key.h4
-rw-r--r--src/mongo/db/query/collation/collator_interface.h4
-rw-r--r--src/mongo/db/query/collation/collator_interface_icu.cpp5
-rw-r--r--src/mongo/db/query/collation/collator_interface_icu.h4
-rw-r--r--src/mongo/db/query/collation/collator_interface_mock.cpp5
-rw-r--r--src/mongo/db/query/collation/collator_interface_mock.h4
-rw-r--r--src/mongo/db/query/index_bounds_builder.cpp3
-rw-r--r--src/mongo/db/query/index_bounds_builder.h2
-rw-r--r--src/mongo/db/query/index_bounds_builder_test.cpp2
-rw-r--r--src/mongo/db/query/index_entry.h2
-rw-r--r--src/mongo/db/query/parsed_projection.cpp2
-rw-r--r--src/mongo/db/query/parsed_projection_test.cpp4
-rw-r--r--src/mongo/db/query/plan_cache_indexability_test.cpp2
-rw-r--r--src/mongo/db/query/plan_cache_test.cpp2
-rw-r--r--src/mongo/db/query/planner_ixselect_test.cpp2
-rw-r--r--src/mongo/db/query/query_planner_params.h2
-rw-r--r--src/mongo/db/query/query_planner_test_fixture.cpp4
-rw-r--r--src/mongo/db/query/query_planner_test_fixture.h2
-rw-r--r--src/mongo/db/query/query_planner_test_lib.cpp2
-rw-r--r--src/mongo/db/query/query_solution_test.cpp2
-rw-r--r--src/mongo/dbtests/matchertests.cpp28
-rw-r--r--src/mongo/dbtests/namespacetests.cpp4
-rw-r--r--src/mongo/dbtests/query_stage_collscan.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_count.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_ensure_sorted.cpp4
-rw-r--r--src/mongo/dbtests/query_stage_fetch.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_multiplan.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_subplan.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_tests.cpp2
92 files changed, 512 insertions, 510 deletions
diff --git a/src/mongo/base/string_data_comparator_interface.h b/src/mongo/base/string_data_comparator_interface.h
index f532aafeae4..a8a4cee7a26 100644
--- a/src/mongo/base/string_data_comparator_interface.h
+++ b/src/mongo/base/string_data_comparator_interface.h
@@ -42,7 +42,7 @@ public:
/**
* Compares two StringData objects.
*/
- virtual int compare(StringData left, StringData right) = 0;
+ virtual int compare(StringData left, StringData right) const = 0;
};
} // namespace mongo
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp
index 7c934fb8c81..0de4ce56a33 100644
--- a/src/mongo/bson/bsonelement.cpp
+++ b/src/mongo/bson/bsonelement.cpp
@@ -381,7 +381,7 @@ std::vector<BSONElement> BSONElement::Array() const {
*/
int BSONElement::woCompare(const BSONElement& e,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
int lt = (int)canonicalType();
int rt = (int)e.canonicalType();
int x = lt - rt;
@@ -853,7 +853,7 @@ std::string escape(const std::string& s, bool escape_slash) {
*/
int compareElementValues(const BSONElement& l,
const BSONElement& r,
- StringData::ComparatorInterface* comparator) {
+ const StringData::ComparatorInterface* comparator) {
int f;
switch (l.type()) {
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index b3e8c3caf98..8db2f2f7722 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -60,7 +60,7 @@ typedef BSONObjBuilder bob;
*/
int compareElementValues(const BSONElement& l,
const BSONElement& r,
- StringData::ComparatorInterface* comparator = nullptr);
+ const StringData::ComparatorInterface* comparator = nullptr);
/** BSONElement represents an "element" in a BSONObj. So for the object { a : 3, b : "abc" },
'a : 3' is the first element (key+value).
@@ -494,7 +494,7 @@ public:
*/
int woCompare(const BSONElement& e,
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
/**
* Functor compatible with std::hash for std::unordered_{map,set}
diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h
index 55d80e7821f..89a24015238 100644
--- a/src/mongo/bson/bsonmisc.h
+++ b/src/mongo/bson/bsonmisc.h
@@ -43,7 +43,7 @@ public:
* string elements. A custom string comparator may be provided, but it must outlive the
* constructed BSONElementCmpWithoutField.
*/
- BSONElementCmpWithoutField(StringData::ComparatorInterface* stringComparator = nullptr)
+ BSONElementCmpWithoutField(const StringData::ComparatorInterface* stringComparator = nullptr)
: _stringComparator(stringComparator) {}
bool operator()(const BSONElement& l, const BSONElement& r) const {
@@ -51,7 +51,7 @@ public:
}
private:
- StringData::ComparatorInterface* _stringComparator;
+ const StringData::ComparatorInterface* _stringComparator;
};
class BSONObjCmp {
@@ -62,7 +62,7 @@ public:
* constructed BSONElementCmpWithoutField.
*/
BSONObjCmp(const BSONObj& order = BSONObj(),
- StringData::ComparatorInterface* stringComparator = nullptr)
+ const StringData::ComparatorInterface* stringComparator = nullptr)
: _order(order), _stringComparator(stringComparator) {}
bool operator()(const BSONObj& l, const BSONObj& r) const {
return l.woCompare(r, _order, true, _stringComparator) < 0;
@@ -73,7 +73,7 @@ public:
private:
BSONObj _order;
- StringData::ComparatorInterface* _stringComparator;
+ const StringData::ComparatorInterface* _stringComparator;
};
typedef std::set<BSONObj, BSONObjCmp> BSONObjSet;
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp
index 8274ab5ccd9..5c19d28a3c3 100644
--- a/src/mongo/bson/bsonobj.cpp
+++ b/src/mongo/bson/bsonobj.cpp
@@ -121,7 +121,7 @@ bool BSONObj::valid() const {
int BSONObj::woCompare(const BSONObj& r,
const Ordering& o,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
if (isEmpty())
return r.isEmpty() ? 0 : -1;
if (r.isEmpty())
@@ -157,7 +157,7 @@ int BSONObj::woCompare(const BSONObj& r,
int BSONObj::woCompare(const BSONObj& r,
const BSONObj& idxKey,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
if (isEmpty())
return r.isEmpty() ? 0 : -1;
if (r.isEmpty())
diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h
index fa39b2d9220..9333670339b 100644
--- a/src/mongo/bson/bsonobj.h
+++ b/src/mongo/bson/bsonobj.h
@@ -404,7 +404,7 @@ public:
int woCompare(const BSONObj& r,
const Ordering& o,
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
/**wo='well ordered'. fields must be in same order in each object.
Ordering is with respect to the signs of the elements
@@ -415,7 +415,7 @@ public:
int woCompare(const BSONObj& r,
const BSONObj& ordering = BSONObj(),
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
bool operator<(const BSONObj& other) const {
return woCompare(other) < 0;
diff --git a/src/mongo/bson/mutable/const_element-inl.h b/src/mongo/bson/mutable/const_element-inl.h
index a7f3864ae17..2d00ec0b797 100644
--- a/src/mongo/bson/mutable/const_element-inl.h
+++ b/src/mongo/bson/mutable/const_element-inl.h
@@ -164,21 +164,24 @@ inline SafeNum ConstElement::getValueSafeNum() const {
return _basis.getValueSafeNum();
}
-inline int ConstElement::compareWithElement(const ConstElement& other,
- bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+inline int ConstElement::compareWithElement(
+ const ConstElement& other,
+ bool considerFieldName,
+ const StringData::ComparatorInterface* comparator) const {
return _basis.compareWithElement(other, considerFieldName, comparator);
}
-inline int ConstElement::compareWithBSONElement(const BSONElement& other,
- bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+inline int ConstElement::compareWithBSONElement(
+ const BSONElement& other,
+ bool considerFieldName,
+ const StringData::ComparatorInterface* comparator) const {
return _basis.compareWithBSONElement(other, considerFieldName, comparator);
}
-inline int ConstElement::compareWithBSONObj(const BSONObj& other,
- bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+inline int ConstElement::compareWithBSONObj(
+ const BSONObj& other,
+ bool considerFieldName,
+ const StringData::ComparatorInterface* comparator) const {
return _basis.compareWithBSONObj(other, considerFieldName, comparator);
}
diff --git a/src/mongo/bson/mutable/const_element.h b/src/mongo/bson/mutable/const_element.h
index 1997de64a32..d9798309204 100644
--- a/src/mongo/bson/mutable/const_element.h
+++ b/src/mongo/bson/mutable/const_element.h
@@ -88,17 +88,20 @@ public:
inline bool isValueMaxKey() const;
inline SafeNum getValueSafeNum() const;
- inline int compareWithElement(const ConstElement& other,
- bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
-
- inline int compareWithBSONElement(const BSONElement& other,
- bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
-
- inline int compareWithBSONObj(const BSONObj& other,
- bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ inline int compareWithElement(
+ const ConstElement& other,
+ bool considerFieldName = true,
+ const StringData::ComparatorInterface* comparator = nullptr) const;
+
+ inline int compareWithBSONElement(
+ const BSONElement& other,
+ bool considerFieldName = true,
+ const StringData::ComparatorInterface* comparator = nullptr) const;
+
+ inline int compareWithBSONObj(
+ const BSONObj& other,
+ bool considerFieldName = true,
+ const StringData::ComparatorInterface* comparator = nullptr) const;
inline void writeTo(BSONObjBuilder* builder) const;
inline void writeArrayTo(BSONArrayBuilder* builder) const;
diff --git a/src/mongo/bson/mutable/document-inl.h b/src/mongo/bson/mutable/document-inl.h
index ec06777e8a5..6942283ceb1 100644
--- a/src/mongo/bson/mutable/document-inl.h
+++ b/src/mongo/bson/mutable/document-inl.h
@@ -32,7 +32,7 @@ namespace mutablebson {
inline int Document::compareWith(const Document& other,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
// We cheat and use Element::compareWithElement since we know that 'other' is a
// Document and has a 'hidden' fieldname that is always indentical across all Document
// instances.
@@ -41,7 +41,7 @@ inline int Document::compareWith(const Document& other,
inline int Document::compareWithBSONObj(const BSONObj& other,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
return root().compareWithBSONObj(other, considerFieldName, comparator);
}
diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp
index 6bb159b0e7c..2afe8c8de96 100644
--- a/src/mongo/bson/mutable/document.cpp
+++ b/src/mongo/bson/mutable/document.cpp
@@ -1487,7 +1487,7 @@ SafeNum Element::getValueSafeNum() const {
int Element::compareWithElement(const ConstElement& other,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
verify(ok());
verify(other.ok());
@@ -1570,7 +1570,7 @@ int Element::compareWithElement(const ConstElement& other,
int Element::compareWithBSONElement(const BSONElement& other,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
verify(ok());
const Document::Impl& impl = getDocument().getImpl();
@@ -1611,7 +1611,7 @@ int Element::compareWithBSONElement(const BSONElement& other,
int Element::compareWithBSONObj(const BSONObj& other,
bool considerFieldName,
- StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator) const {
verify(ok());
const Document::Impl& impl = getDocument().getImpl();
diff --git a/src/mongo/bson/mutable/document.h b/src/mongo/bson/mutable/document.h
index cca50443311..60cbaab3cde 100644
--- a/src/mongo/bson/mutable/document.h
+++ b/src/mongo/bson/mutable/document.h
@@ -279,12 +279,13 @@ public:
/** Compare this Document to 'other' with the semantics of BSONObj::woCompare. */
inline int compareWith(const Document& other,
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
/** Compare this Document to 'other' with the semantics of BSONObj::woCompare. */
- inline int compareWithBSONObj(const BSONObj& other,
- bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ inline int compareWithBSONObj(
+ const BSONObj& other,
+ bool considerFieldName = true,
+ const StringData::ComparatorInterface* comparator = nullptr) const;
//
diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h
index ee0d6de3d45..690894b285d 100644
--- a/src/mongo/bson/mutable/element.h
+++ b/src/mongo/bson/mutable/element.h
@@ -352,7 +352,7 @@ public:
*/
int compareWithElement(const ConstElement& other,
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
/** Compare this Element with BSONElement 'other'. You should not call this on the root
* Element of the Document because the root Element does not have a field name. Use
@@ -364,7 +364,7 @@ public:
*/
int compareWithBSONElement(const BSONElement& other,
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
/** Compare this Element, which must be an Object or an Array, with 'other'.
*
@@ -374,7 +374,7 @@ public:
*/
int compareWithBSONObj(const BSONObj& other,
bool considerFieldName = true,
- StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator = nullptr) const;
//
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index c680ce41b79..7c359b728cb 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -974,7 +974,7 @@ Status Collection::setValidationAction(OperationContext* txn, StringData newActi
return Status::OK();
}
-CollatorInterface* Collection::getDefaultCollator() const {
+const CollatorInterface* Collection::getDefaultCollator() const {
return _collator.get();
}
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index b718413e161..f5e4e0fe700 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -436,7 +436,7 @@ public:
* Get a pointer to the collection's default collator. The pointer must not be used after this
* Collection is destroyed.
*/
- CollatorInterface* getDefaultCollator() const;
+ const CollatorInterface* getDefaultCollator() const;
private:
/**
diff --git a/src/mongo/db/catalog/index_catalog_entry.h b/src/mongo/db/catalog/index_catalog_entry.h
index 909b93520ba..5d9aad728ac 100644
--- a/src/mongo/db/catalog/index_catalog_entry.h
+++ b/src/mongo/db/catalog/index_catalog_entry.h
@@ -87,7 +87,7 @@ public:
return _filterExpression.get();
}
- CollatorInterface* getCollator() {
+ const CollatorInterface* getCollator() const {
return _collator.get();
}
diff --git a/src/mongo/db/clientlistplugin.cpp b/src/mongo/db/clientlistplugin.cpp
index ef241ed7185..2aef3af715c 100644
--- a/src/mongo/db/clientlistplugin.cpp
+++ b/src/mongo/db/clientlistplugin.cpp
@@ -168,7 +168,7 @@ public:
BSONObjBuilder& result) {
unique_ptr<MatchExpression> filter;
if (cmdObj["filter"].isABSONObj()) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
cmdObj["filter"].Obj(), ExtensionsCallbackDisallowExtensions(), collator);
if (!statusWithMatcher.isOK()) {
diff --git a/src/mongo/db/commands/current_op.cpp b/src/mongo/db/commands/current_op.cpp
index 2f5798b410f..0e25e16f443 100644
--- a/src/mongo/db/commands/current_op.cpp
+++ b/src/mongo/db/commands/current_op.cpp
@@ -105,7 +105,7 @@ public:
// collection, we pass in a fake collection name (and this is okay, because $where parsing
// only relies on the database part of the namespace).
const NamespaceString fakeNS(db, "$cmd");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
const Matcher matcher(filter, ExtensionsCallbackReal(txn, &fakeNS), collator);
BSONArrayBuilder inprogBuilder(result.subarrayStart("inprog"));
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index a20179c2bae..ae5dcbe5fea 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -192,7 +192,7 @@ public:
result, Status(ErrorCodes::BadValue, "\"filter\" must be an object"));
}
// The collator is null because collection objects are compared using binary comparison.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
filterElt.Obj(), ExtensionsCallbackDisallowExtensions(), collator);
if (!statusWithMatcher.isOK()) {
diff --git a/src/mongo/db/exec/ensure_sorted.cpp b/src/mongo/db/exec/ensure_sorted.cpp
index 1fef4b191ff..680254926a6 100644
--- a/src/mongo/db/exec/ensure_sorted.cpp
+++ b/src/mongo/db/exec/ensure_sorted.cpp
@@ -45,7 +45,7 @@ const char* EnsureSortedStage::kStageType = "ENSURE_SORTED";
EnsureSortedStage::EnsureSortedStage(OperationContext* opCtx,
BSONObj pattern,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
WorkingSet* ws,
PlanStage* child)
: PlanStage(kStageType, opCtx), _ws(ws), _collator(collator) {
diff --git a/src/mongo/db/exec/ensure_sorted.h b/src/mongo/db/exec/ensure_sorted.h
index a7f9bd45107..45a2ab95a60 100644
--- a/src/mongo/db/exec/ensure_sorted.h
+++ b/src/mongo/db/exec/ensure_sorted.h
@@ -45,7 +45,7 @@ class EnsureSortedStage final : public PlanStage {
public:
EnsureSortedStage(OperationContext* opCtx,
BSONObj pattern,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
WorkingSet* ws,
PlanStage* child);
@@ -76,7 +76,7 @@ private:
// Null if this ensure sorted stage orders strings according to simple binary compare. If
// non-null, represents the collator used to compare strings.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
// The sort key of the previous result.
BSONObj _prevSortKey;
diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp
index 65bd1defd98..83ac0a6d5bd 100644
--- a/src/mongo/db/exec/geo_near.cpp
+++ b/src/mongo/db/exec/geo_near.cpp
@@ -744,7 +744,7 @@ GeoNear2DSphereStage::GeoNear2DSphereStage(const GeoNearParams& nearParams,
_specificStats.indexName = s2Index->indexName();
_specificStats.indexVersion = s2Index->version();
// TODO SERVER-23968: change nullptr to the appropriate collator.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ExpressionParams::initialize2dsphereParams(s2Index->infoObj(), collator, &_indexParams);
}
diff --git a/src/mongo/db/exec/merge_sort.h b/src/mongo/db/exec/merge_sort.h
index 208af0e044f..e0ff8d40fee 100644
--- a/src/mongo/db/exec/merge_sort.h
+++ b/src/mongo/db/exec/merge_sort.h
@@ -90,7 +90,7 @@ private:
// Null if this merge sort stage orders strings according to simple binary compare. If non-null,
// represents the collator used to compare strings.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
// Are we deduplicating on RecordId?
bool _dedup;
@@ -127,7 +127,7 @@ private:
// The comparison function used in our priority queue.
class StageWithValueComparison {
public:
- StageWithValueComparison(WorkingSet* ws, BSONObj pattern, CollatorInterface* collator)
+ StageWithValueComparison(WorkingSet* ws, BSONObj pattern, const CollatorInterface* collator)
: _ws(ws), _pattern(pattern), _collator(collator) {}
// Is lhs less than rhs? Note that priority_queue is a max heap by default so we invert
@@ -137,7 +137,7 @@ private:
private:
WorkingSet* _ws;
BSONObj _pattern;
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
// The min heap of the results we're returning.
@@ -160,7 +160,7 @@ public:
// Null if this merge sort stage orders strings according to simple binary compare. If non-null,
// represents the collator used to compare strings.
- CollatorInterface* collator;
+ const CollatorInterface* collator;
// Do we deduplicate on RecordId?
bool dedup;
diff --git a/src/mongo/db/exec/projection.h b/src/mongo/db/exec/projection.h
index d9150c22df2..a7422eb180f 100644
--- a/src/mongo/db/exec/projection.h
+++ b/src/mongo/db/exec/projection.h
@@ -73,7 +73,7 @@ struct ProjectionStageParams {
// The collator this operation should use to compare strings. If null, the collation is a simple
// binary compare.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
};
/**
diff --git a/src/mongo/db/exec/projection_exec.cpp b/src/mongo/db/exec/projection_exec.cpp
index d672e9e1027..383edf740f7 100644
--- a/src/mongo/db/exec/projection_exec.cpp
+++ b/src/mongo/db/exec/projection_exec.cpp
@@ -75,7 +75,7 @@ ProjectionExec::ProjectionExec()
ProjectionExec::ProjectionExec(const BSONObj& spec,
const MatchExpression* queryExpression,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
const ExtensionsCallback& extensionsCallback)
: _include(true),
_special(false),
diff --git a/src/mongo/db/exec/projection_exec.h b/src/mongo/db/exec/projection_exec.h
index 0cf9b37a940..b06340e5f12 100644
--- a/src/mongo/db/exec/projection_exec.h
+++ b/src/mongo/db/exec/projection_exec.h
@@ -68,7 +68,7 @@ public:
ProjectionExec(const BSONObj& spec,
const MatchExpression* queryExpression,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
const ExtensionsCallback& extensionsCallback);
~ProjectionExec();
@@ -183,7 +183,7 @@ private:
// The collator this projection should use to compare strings. Needed for projection operators
// that perform matching (e.g. elemMatch projection). If null, the collation is a simple binary
// compare.
- CollatorInterface* _collator = nullptr;
+ const CollatorInterface* _collator = nullptr;
};
} // namespace mongo
diff --git a/src/mongo/db/exec/projection_exec_test.cpp b/src/mongo/db/exec/projection_exec_test.cpp
index d0df0e2ee5a..4c9689f544e 100644
--- a/src/mongo/db/exec/projection_exec_test.cpp
+++ b/src/mongo/db/exec/projection_exec_test.cpp
@@ -50,7 +50,7 @@ using std::unique_ptr;
* Utility function to create MatchExpression
*/
unique_ptr<MatchExpression> parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(status.isOK());
@@ -78,7 +78,7 @@ void testTransform(const char* specStr,
const char* queryStr,
const char* objStr,
WorkingSetComputedData* data,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
bool expectedStatusOK,
const char* expectedObjStr) {
// Create projection exec object.
diff --git a/src/mongo/db/exec/sort.cpp b/src/mongo/db/exec/sort.cpp
index 279b8ea4391..ee7d4ab4d15 100644
--- a/src/mongo/db/exec/sort.cpp
+++ b/src/mongo/db/exec/sort.cpp
@@ -56,7 +56,7 @@ using stdx::make_unique;
// static
const char* SortStage::kStageType = "SORT";
-SortStage::WorkingSetComparator::WorkingSetComparator(BSONObj p, CollatorInterface* c)
+SortStage::WorkingSetComparator::WorkingSetComparator(BSONObj p, const CollatorInterface* c)
: pattern(p), collator(c) {}
bool SortStage::WorkingSetComparator::operator()(const SortableDataItem& lhs,
diff --git a/src/mongo/db/exec/sort.h b/src/mongo/db/exec/sort.h
index 096697b7fdb..650eb9174d1 100644
--- a/src/mongo/db/exec/sort.h
+++ b/src/mongo/db/exec/sort.h
@@ -57,7 +57,7 @@ public:
// Null if this sort stage orders strings according to simple binary compare. If non-null,
// represents the collator used to compare strings.
- CollatorInterface* collator;
+ const CollatorInterface* collator;
// Equal to 0 for no limit.
size_t limit;
@@ -110,7 +110,7 @@ private:
// Null if this sort stage orders strings according to simple binary compare. If non-null,
// represents the collator used to compare strings.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
// Equal to 0 for no limit.
size_t _limit;
@@ -139,13 +139,13 @@ private:
// Keys are compared using BSONObj::woCompare() with RecordId as a tie-breaker. 'collator' is
// passed to woCompare() to perform string comparisons.
struct WorkingSetComparator {
- explicit WorkingSetComparator(BSONObj p, CollatorInterface* collator);
+ explicit WorkingSetComparator(BSONObj p, const CollatorInterface* collator);
bool operator()(const SortableDataItem& lhs, const SortableDataItem& rhs) const;
BSONObj pattern;
- CollatorInterface* collator;
+ const CollatorInterface* collator;
};
/**
diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp
index d43a892bd8c..f5316a7a94c 100644
--- a/src/mongo/db/exec/stagedebug_cmd.cpp
+++ b/src/mongo/db/exec/stagedebug_cmd.cpp
@@ -249,7 +249,7 @@ public:
}
BSONObj argObj = e.Obj();
if (filterTag == e.fieldName()) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
argObj, ExtensionsCallbackReal(txn, &collection->ns()), collator);
if (!statusWithMatcher.isOK()) {
diff --git a/src/mongo/db/index/btree_key_generator.cpp b/src/mongo/db/index/btree_key_generator.cpp
index 14c48085b03..ad99eaa8a77 100644
--- a/src/mongo/db/index/btree_key_generator.cpp
+++ b/src/mongo/db/index/btree_key_generator.cpp
@@ -219,7 +219,7 @@ void BtreeKeyGeneratorV0::getKeysImpl(std::vector<const char*> fieldNames,
BtreeKeyGeneratorV1::BtreeKeyGeneratorV1(std::vector<const char*> fieldNames,
std::vector<BSONElement> fixed,
bool isSparse,
- CollatorInterface* collator)
+ const CollatorInterface* collator)
: BtreeKeyGenerator(fieldNames, fixed, isSparse),
_emptyPositionalInfo(fieldNames.size()),
_collator(collator) {
diff --git a/src/mongo/db/index/btree_key_generator.h b/src/mongo/db/index/btree_key_generator.h
index 7ddbe8a0732..7d33001a594 100644
--- a/src/mongo/db/index/btree_key_generator.h
+++ b/src/mongo/db/index/btree_key_generator.h
@@ -100,7 +100,7 @@ public:
BtreeKeyGeneratorV1(std::vector<const char*> fieldNames,
std::vector<BSONElement> fixed,
bool isSparse,
- CollatorInterface* collator);
+ const CollatorInterface* collator);
virtual ~BtreeKeyGeneratorV1() {}
@@ -250,7 +250,7 @@ private:
// Null if this key generator orders strings according to the simple binary compare. If
// non-null, represents the collator used to generate index keys for indexed strings.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
} // namespace mongo
diff --git a/src/mongo/db/index/btree_key_generator_test.cpp b/src/mongo/db/index/btree_key_generator_test.cpp
index b258487d114..ce0b53dd6d8 100644
--- a/src/mongo/db/index/btree_key_generator_test.cpp
+++ b/src/mongo/db/index/btree_key_generator_test.cpp
@@ -83,7 +83,7 @@ bool testKeygen(const BSONObj& kp,
const BSONObjSet& expectedKeys,
const MultikeyPaths& expectedMultikeyPaths,
bool sparse = false,
- CollatorInterface* collator = nullptr) {
+ const CollatorInterface* collator = nullptr) {
invariant(expectedMultikeyPaths.size() == static_cast<size_t>(kp.nFields()));
//
diff --git a/src/mongo/db/index/expression_keys_private.cpp b/src/mongo/db/index/expression_keys_private.cpp
index e8a9a3b0a2e..99f2b889c01 100644
--- a/src/mongo/db/index/expression_keys_private.cpp
+++ b/src/mongo/db/index/expression_keys_private.cpp
@@ -149,7 +149,7 @@ void getS2GeoKeys(const BSONObj& document,
* Expands array and appends items to 'out'.
* Used by getOneLiteralKey.
*/
-void getS2LiteralKeysArray(const BSONObj& obj, CollatorInterface* collator, BSONObjSet* out) {
+void getS2LiteralKeysArray(const BSONObj& obj, const CollatorInterface* collator, BSONObjSet* out) {
BSONObjIterator objIt(obj);
if (!objIt.more()) {
// Empty arrays are indexed as undefined.
@@ -171,7 +171,9 @@ void getS2LiteralKeysArray(const BSONObj& obj, CollatorInterface* collator, BSON
* Otherwise, adds 'elt' as a single element.
* Used by getLiteralKeys.
*/
-void getS2OneLiteralKey(const BSONElement& elt, CollatorInterface* collator, BSONObjSet* out) {
+void getS2OneLiteralKey(const BSONElement& elt,
+ const CollatorInterface* collator,
+ BSONObjSet* out) {
if (Array == elt.type()) {
getS2LiteralKeysArray(elt.Obj(), collator, out);
} else {
@@ -187,7 +189,7 @@ void getS2OneLiteralKey(const BSONElement& elt, CollatorInterface* collator, BSO
* Used by getS2Keys.
*/
void getS2LiteralKeys(const BSONElementSet& elements,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
BSONObjSet* out) {
if (0 == elements.size()) {
// Missing fields are indexed as null.
@@ -324,7 +326,7 @@ void ExpressionKeysPrivate::getHashKeys(const BSONObj& obj,
HashSeed seed,
int hashVersion,
bool isSparse,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
BSONObjSet* keys) {
const char* cstr = hashedField.c_str();
BSONElement fieldVal = obj.getFieldDottedOrArray(cstr);
diff --git a/src/mongo/db/index/expression_keys_private.h b/src/mongo/db/index/expression_keys_private.h
index 4267e4d66db..b84acbcae11 100644
--- a/src/mongo/db/index/expression_keys_private.h
+++ b/src/mongo/db/index/expression_keys_private.h
@@ -80,7 +80,7 @@ public:
HashSeed seed,
int hashVersion,
bool isSparse,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
BSONObjSet* keys);
/**
diff --git a/src/mongo/db/index/expression_params.cpp b/src/mongo/db/index/expression_params.cpp
index a3f201ceb12..e0ab49c303e 100644
--- a/src/mongo/db/index/expression_params.cpp
+++ b/src/mongo/db/index/expression_params.cpp
@@ -124,7 +124,7 @@ void ExpressionParams::parseHaystackParams(const BSONObj& infoObj,
}
void ExpressionParams::initialize2dsphereParams(const BSONObj& infoObj,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
S2IndexingParams* out) {
// Set up basic params.
out->collator = collator;
diff --git a/src/mongo/db/index/expression_params.h b/src/mongo/db/index/expression_params.h
index 9eb28132ceb..21cf7c298c0 100644
--- a/src/mongo/db/index/expression_params.h
+++ b/src/mongo/db/index/expression_params.h
@@ -55,7 +55,7 @@ void parseHaystackParams(const BSONObj& infoObj,
double* bucketSizeOut);
void initialize2dsphereParams(const BSONObj& infoObj,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
S2IndexingParams* out);
} // namespace ExpressionParams
diff --git a/src/mongo/db/index/hash_access_method.h b/src/mongo/db/index/hash_access_method.h
index 610bf6db015..5af9d0e4153 100644
--- a/src/mongo/db/index/hash_access_method.h
+++ b/src/mongo/db/index/hash_access_method.h
@@ -61,7 +61,7 @@ private:
// Null if this index orders strings according to the simple binary compare. If non-null,
// represents the collator used to generate index keys for indexed strings.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
} // namespace mongo
diff --git a/src/mongo/db/index/s2_access_method.h b/src/mongo/db/index/s2_access_method.h
index a6b10d625f5..db615977461 100644
--- a/src/mongo/db/index/s2_access_method.h
+++ b/src/mongo/db/index/s2_access_method.h
@@ -55,7 +55,7 @@ private:
// Null if this index orders strings according to the simple binary compare. If non-null,
// represents the collator used to generate index keys for indexed strings.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
} // namespace mongo
diff --git a/src/mongo/db/index/s2_common.h b/src/mongo/db/index/s2_common.h
index 5afbbec5fa0..83153395006 100644
--- a/src/mongo/db/index/s2_common.h
+++ b/src/mongo/db/index/s2_common.h
@@ -74,7 +74,7 @@ struct S2IndexingParams {
double radius;
// Null if this index orders strings according to the simple binary compare. If non-null,
// represents the collator used to generate index keys for indexed strings.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
std::string toString() const;
diff --git a/src/mongo/db/index/s2_key_generator_test.cpp b/src/mongo/db/index/s2_key_generator_test.cpp
index e13c14c133d..a26a43337e8 100644
--- a/src/mongo/db/index/s2_key_generator_test.cpp
+++ b/src/mongo/db/index/s2_key_generator_test.cpp
@@ -71,7 +71,7 @@ long long getCellID(int x, int y) {
BSONObj keyPattern = fromjson("{a: '2dsphere'}");
BSONObj infoObj = fromjson("{key: {a: '2dsphere'}, '2dsphereIndexVersion': 3}");
S2IndexingParams params;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
BSONObjSet keys;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &keys);
@@ -240,7 +240,7 @@ TEST(S2KeyGeneratorTest, NoCollation) {
BSONObj keyPattern = fromjson("{a: '2dsphere', b: 1}");
BSONObj infoObj = fromjson("{key: {a: '2dsphere', b: 1}, '2dsphereIndexVersion': 3}");
S2IndexingParams params;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ExpressionParams::initialize2dsphereParams(infoObj, collator, &params);
BSONObjSet actualKeys;
ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys);
diff --git a/src/mongo/db/matcher/expression_algo_test.cpp b/src/mongo/db/matcher/expression_algo_test.cpp
index 807b35aee62..946120d353d 100644
--- a/src/mongo/db/matcher/expression_algo_test.cpp
+++ b/src/mongo/db/matcher/expression_algo_test.cpp
@@ -52,7 +52,7 @@ using std::unique_ptr;
class ParsedMatchExpression {
public:
ParsedMatchExpression(const std::string& str) : _obj(fromjson(str)) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(_obj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(result.getStatus());
@@ -72,7 +72,7 @@ TEST(ExpressionAlgoIsSubsetOf, NullAndOmittedField) {
// Verify that ComparisonMatchExpression::init() prohibits creating a match expression with
// an Undefined type.
BSONObj undefined = fromjson("{a: undefined}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_EQUALS(ErrorCodes::BadValue,
MatchExpressionParser::parse(
undefined, ExtensionsCallbackDisallowExtensions(), collator).getStatus());
@@ -655,7 +655,7 @@ TEST(ExpressionAlgoIsSubsetOf, Compare_Exists_NE) {
TEST(IsIndependent, AndIsIndependentOnlyIfChildrenAre) {
BSONObj matchPredicate = fromjson("{$and: [{a: 1}, {b: 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -667,7 +667,7 @@ TEST(IsIndependent, AndIsIndependentOnlyIfChildrenAre) {
TEST(IsIndependent, ElemMatchIsNotIndependent) {
BSONObj matchPredicate = fromjson("{x: {$elemMatch: {y: 1}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -680,7 +680,7 @@ TEST(IsIndependent, ElemMatchIsNotIndependent) {
TEST(IsIndependent, NorIsIndependentOnlyIfChildrenAre) {
BSONObj matchPredicate = fromjson("{$nor: [{a: 1}, {b: 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -692,7 +692,7 @@ TEST(IsIndependent, NorIsIndependentOnlyIfChildrenAre) {
TEST(IsIndependent, NotIsIndependentOnlyIfChildrenAre) {
BSONObj matchPredicate = fromjson("{a: {$not: {$eq: 1}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -704,7 +704,7 @@ TEST(IsIndependent, NotIsIndependentOnlyIfChildrenAre) {
TEST(IsIndependent, OrIsIndependentOnlyIfChildrenAre) {
BSONObj matchPredicate = fromjson("{$or: [{a: 1}, {b: 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -716,7 +716,7 @@ TEST(IsIndependent, OrIsIndependentOnlyIfChildrenAre) {
TEST(IsIndependent, AndWithDottedFieldPathsIsNotIndependent) {
BSONObj matchPredicate = fromjson("{$and: [{'a': 1}, {'a.b': 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -728,7 +728,7 @@ TEST(IsIndependent, AndWithDottedFieldPathsIsNotIndependent) {
TEST(IsIndependent, BallIsIndependentOfBalloon) {
BSONObj matchPredicate = fromjson("{'a.ball': 4}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -741,7 +741,7 @@ TEST(IsIndependent, BallIsIndependentOfBalloon) {
TEST(SplitMatchExpression, AndWithSplittableChildrenIsSplittable) {
BSONObj matchPredicate = fromjson("{$and: [{a: 1}, {b: 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -763,7 +763,7 @@ TEST(SplitMatchExpression, AndWithSplittableChildrenIsSplittable) {
TEST(SplitMatchExpression, NorWithIndependentChildrenIsSplittable) {
BSONObj matchPredicate = fromjson("{$nor: [{a: 1}, {b: 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -785,7 +785,7 @@ TEST(SplitMatchExpression, NorWithIndependentChildrenIsSplittable) {
TEST(SplitMatchExpression, NotWithIndependentChildIsSplittable) {
BSONObj matchPredicate = fromjson("{x: {$not: {$gt: 4}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -803,7 +803,7 @@ TEST(SplitMatchExpression, NotWithIndependentChildIsSplittable) {
TEST(SplitMatchExpression, OrWithOnlyIndependentChildrenIsNotSplittable) {
BSONObj matchPredicate = fromjson("{$or: [{a: 1}, {b: 1}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -824,7 +824,7 @@ TEST(SplitMatchExpression, ComplexMatchExpressionSplitsCorrectly) {
"{$and: [{x: {$not: {$size: 2}}},"
"{$or: [{'a.b' : 3}, {'a.b.c': 4}]},"
"{$nor: [{x: {$gt: 4}}, {$and: [{x: {$not: {$eq: 1}}}, {y: 3}]}]}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(status.getStatus());
@@ -850,7 +850,7 @@ TEST(SplitMatchExpression, ComplexMatchExpressionSplitsCorrectly) {
TEST(MapOverMatchExpression, DoesMapOverLogicalNodes) {
BSONObj matchPredicate = fromjson("{a: {$not: {$eq: 1}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
auto swMatchExpression =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(swMatchExpression.getStatus());
@@ -868,7 +868,7 @@ TEST(MapOverMatchExpression, DoesMapOverLogicalNodes) {
TEST(MapOverMatchExpression, DoesMapOverLeafNodes) {
BSONObj matchPredicate = fromjson("{a: {$not: {$eq: 1}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
auto swMatchExpression =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(swMatchExpression.getStatus());
@@ -886,7 +886,7 @@ TEST(MapOverMatchExpression, DoesMapOverLeafNodes) {
TEST(MapOverMatchExpression, DoesPassPath) {
BSONObj matchPredicate = fromjson("{a: {$elemMatch: {b: 1}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
auto swMatchExpression =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(swMatchExpression.getStatus());
@@ -905,7 +905,7 @@ TEST(MapOverMatchExpression, DoesPassPath) {
TEST(MapOverMatchExpression, DoesMapOverNodesWithMultipleChildren) {
BSONObj matchPredicate = fromjson("{$and: [{a: {$gt: 1}}, {b: {$lte: 2}}]}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
auto swMatchExpression =
MatchExpressionParser::parse(matchPredicate, ExtensionsCallbackNoop(), collator);
ASSERT_OK(swMatchExpression.getStatus());
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp
index e3ef241ef87..8fbc971221b 100644
--- a/src/mongo/db/matcher/expression_array_test.cpp
+++ b/src/mongo/db/matcher/expression_array_test.cpp
@@ -44,7 +44,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementSingle) {
BSONObj baseOperand = BSON("b" << 5);
BSONObj match = BSON("a" << BSON_ARRAY(BSON("b" << 5.0)));
BSONObj notMatch = BSON("a" << BSON_ARRAY(BSON("b" << 6)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("b", baseOperand["b"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -57,7 +57,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementArray) {
BSONObj baseOperand = BSON("1" << 5);
BSONObj match = BSON("a" << BSON_ARRAY(BSON_ARRAY('s' << 5.0)));
BSONObj notMatch = BSON("a" << BSON_ARRAY(BSON_ARRAY(5 << 6)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("1", baseOperand["1"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -74,7 +74,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementMultiple) {
BSONObj notMatch2 = BSON("a" << BSON_ARRAY(BSON("b" << 6 << "c" << 7)));
BSONObj notMatch3 = BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(5 << 6))));
BSONObj match = BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(5 << 6) << "c" << 7)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq1(new EqualityMatchExpression(collator));
ASSERT(eq1->init("b", baseOperand1["b"]).isOK());
unique_ptr<ComparisonMatchExpression> eq2(new EqualityMatchExpression(collator));
@@ -97,7 +97,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementMultiple) {
TEST(ElemMatchObjectMatchExpression, MatchesNonArray) {
BSONObj baseOperand = BSON("b" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("b", baseOperand["b"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -111,7 +111,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesNonArray) {
TEST(ElemMatchObjectMatchExpression, MatchesArrayObject) {
BSONObj baseOperand = BSON("b" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("b", baseOperand["b"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -124,7 +124,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesArrayObject) {
TEST(ElemMatchObjectMatchExpression, MatchesMultipleNamedValues) {
BSONObj baseOperand = BSON("c" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("c", baseOperand["c"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -137,7 +137,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesMultipleNamedValues) {
TEST(ElemMatchObjectMatchExpression, ElemMatchKey) {
BSONObj baseOperand = BSON("c" << 6);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("c", baseOperand["c"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -178,7 +178,7 @@ TEST(ElemMatchValueMatchExpression, MatchesElementSingle) {
BSONObj baseOperand = BSON("$gt" << 5);
BSONObj match = BSON("a" << BSON_ARRAY(6));
BSONObj notMatch = BSON("a" << BSON_ARRAY(4));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
@@ -193,7 +193,7 @@ TEST(ElemMatchValueMatchExpression, MatchesElementMultiple) {
BSONObj notMatch1 = BSON("a" << BSON_ARRAY(0 << 1));
BSONObj notMatch2 = BSON("a" << BSON_ARRAY(10 << 11));
BSONObj match = BSON("a" << BSON_ARRAY(0 << 5 << 11));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
ASSERT(gt->init("", baseOperand1["$gt"]).isOK());
unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator));
@@ -211,7 +211,7 @@ TEST(ElemMatchValueMatchExpression, MatchesElementMultiple) {
TEST(ElemMatchValueMatchExpression, MatchesNonArray) {
BSONObj baseOperand = BSON("$gt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchObjectMatchExpression op;
@@ -224,7 +224,7 @@ TEST(ElemMatchValueMatchExpression, MatchesNonArray) {
TEST(ElemMatchValueMatchExpression, MatchesArrayScalar) {
BSONObj baseOperand = BSON("$gt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
@@ -236,7 +236,7 @@ TEST(ElemMatchValueMatchExpression, MatchesArrayScalar) {
TEST(ElemMatchValueMatchExpression, MatchesMultipleNamedValues) {
BSONObj baseOperand = BSON("$gt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
@@ -249,7 +249,7 @@ TEST(ElemMatchValueMatchExpression, MatchesMultipleNamedValues) {
TEST(ElemMatchValueMatchExpression, ElemMatchKey) {
BSONObj baseOperand = BSON("$gt" << 6);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
@@ -287,7 +287,7 @@ TEST( ElemMatchValueMatchExpression, MatchesIndexKey ) {
TEST(AndOfElemMatch, MatchesElement) {
BSONObj baseOperanda1 = BSON("a" << 1);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eqa1(new EqualityMatchExpression(collator));
ASSERT(eqa1->init("a", baseOperanda1["a"]).isOK());
@@ -345,7 +345,7 @@ TEST(AndOfElemMatch, MatchesElement) {
TEST(AndOfElemMatch, Matches) {
BSONObj baseOperandgt1 = BSON("$gt" << 1);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> gt1(new GTMatchExpression(collator));
ASSERT(gt1->init("", baseOperandgt1["$gt"]).isOK());
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp
index 56e83a8e996..3e7e2a4b909 100644
--- a/src/mongo/db/matcher/expression_leaf.cpp
+++ b/src/mongo/db/matcher/expression_leaf.cpp
@@ -532,7 +532,7 @@ bool TypeMatchExpression::equivalent(const MatchExpression* other) const {
// --------
-ArrayFilterEntries::ArrayFilterEntries(CollatorInterface* collator)
+ArrayFilterEntries::ArrayFilterEntries(const CollatorInterface* collator)
: _hasNull(false), _hasEmptyArray(false), _equalities(collator), _collator(collator) {}
ArrayFilterEntries::~ArrayFilterEntries() {
diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h
index d6ba6d83d7c..b39e709d3e6 100644
--- a/src/mongo/db/matcher/expression_leaf.h
+++ b/src/mongo/db/matcher/expression_leaf.h
@@ -87,7 +87,7 @@ public:
/**
* 'collator' must outlive the ComparisonMatchExpression and any clones made of it.
*/
- ComparisonMatchExpression(MatchType type, CollatorInterface* collator)
+ ComparisonMatchExpression(MatchType type, const CollatorInterface* collator)
: LeafMatchExpression(type), _collator(collator) {}
Status init(StringData path, const BSONElement& rhs);
@@ -110,13 +110,13 @@ public:
return _rhs;
}
- CollatorInterface* getCollator() const {
+ const CollatorInterface* getCollator() const {
return _collator;
}
protected:
BSONElement _rhs;
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
//
@@ -125,7 +125,7 @@ protected:
class EqualityMatchExpression : public ComparisonMatchExpression {
public:
- EqualityMatchExpression(CollatorInterface* collator)
+ EqualityMatchExpression(const CollatorInterface* collator)
: ComparisonMatchExpression(EQ, collator) {}
virtual std::unique_ptr<MatchExpression> shallowClone() const {
std::unique_ptr<ComparisonMatchExpression> e =
@@ -140,7 +140,8 @@ public:
class LTEMatchExpression : public ComparisonMatchExpression {
public:
- LTEMatchExpression(CollatorInterface* collator) : ComparisonMatchExpression(LTE, collator) {}
+ LTEMatchExpression(const CollatorInterface* collator)
+ : ComparisonMatchExpression(LTE, collator) {}
virtual std::unique_ptr<MatchExpression> shallowClone() const {
std::unique_ptr<ComparisonMatchExpression> e =
stdx::make_unique<LTEMatchExpression>(_collator);
@@ -154,7 +155,8 @@ public:
class LTMatchExpression : public ComparisonMatchExpression {
public:
- LTMatchExpression(CollatorInterface* collator) : ComparisonMatchExpression(LT, collator) {}
+ LTMatchExpression(const CollatorInterface* collator)
+ : ComparisonMatchExpression(LT, collator) {}
virtual std::unique_ptr<MatchExpression> shallowClone() const {
std::unique_ptr<ComparisonMatchExpression> e =
stdx::make_unique<LTMatchExpression>(_collator);
@@ -168,7 +170,8 @@ public:
class GTMatchExpression : public ComparisonMatchExpression {
public:
- GTMatchExpression(CollatorInterface* collator) : ComparisonMatchExpression(GT, collator) {}
+ GTMatchExpression(const CollatorInterface* collator)
+ : ComparisonMatchExpression(GT, collator) {}
virtual std::unique_ptr<MatchExpression> shallowClone() const {
std::unique_ptr<ComparisonMatchExpression> e =
stdx::make_unique<GTMatchExpression>(_collator);
@@ -182,7 +185,8 @@ public:
class GTEMatchExpression : public ComparisonMatchExpression {
public:
- GTEMatchExpression(CollatorInterface* collator) : ComparisonMatchExpression(GTE, collator) {}
+ GTEMatchExpression(const CollatorInterface* collator)
+ : ComparisonMatchExpression(GTE, collator) {}
virtual std::unique_ptr<MatchExpression> shallowClone() const {
std::unique_ptr<ComparisonMatchExpression> e =
stdx::make_unique<GTEMatchExpression>(_collator);
@@ -314,7 +318,7 @@ class ArrayFilterEntries {
MONGO_DISALLOW_COPYING(ArrayFilterEntries);
public:
- ArrayFilterEntries(CollatorInterface* collator);
+ ArrayFilterEntries(const CollatorInterface* collator);
~ArrayFilterEntries();
Status addEquality(const BSONElement& e);
@@ -347,7 +351,7 @@ public:
return _equalities.size() + _regexes.size();
}
- CollatorInterface* getCollator() const {
+ const CollatorInterface* getCollator() const {
return _collator;
}
@@ -364,7 +368,7 @@ private:
bool _hasEmptyArray;
BSONElementSet _equalities;
std::vector<RegexMatchExpression*> _regexes;
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
/**
@@ -375,7 +379,7 @@ public:
/**
* 'collator' must outlive the InMatchExpression and any clones made of it.
*/
- InMatchExpression(CollatorInterface* collator)
+ InMatchExpression(const CollatorInterface* collator)
: LeafMatchExpression(MATCH_IN), _arrayEntries(collator) {}
Status init(StringData path);
@@ -399,7 +403,7 @@ public:
return _arrayEntries;
}
- CollatorInterface* getCollator() const {
+ const CollatorInterface* getCollator() const {
return _arrayEntries.getCollator();
}
diff --git a/src/mongo/db/matcher/expression_leaf_test.cpp b/src/mongo/db/matcher/expression_leaf_test.cpp
index 78e9bb15c8d..20b7fd5b098 100644
--- a/src/mongo/db/matcher/expression_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_leaf_test.cpp
@@ -60,7 +60,7 @@ TEST(ComparisonMatchExpression, ComparisonMatchExpressionsWithEqualCollatorsAreE
TEST(ComparisonMatchExpression, StringMatchingWithNullCollatorUsesBinaryComparison) {
BSONObj operand = BSON("a"
<< "string");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
ASSERT(eq.init("a", operand["a"]).isOK());
ASSERT(!eq.matchesBSON(BSON("a"
@@ -84,7 +84,7 @@ TEST(EqOp, MatchesElement) {
BSONObj match = BSON("a" << 5.0);
BSONObj notMatch = BSON("a" << 6);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("", operand["a"]);
ASSERT(eq.matchesSingleElement(match.firstElement()));
@@ -95,14 +95,14 @@ TEST(EqOp, MatchesElement) {
TEST(EqOp, InvalidEooOperand) {
BSONObj operand;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
ASSERT(!eq.init("", operand.firstElement()).isOK());
}
TEST(EqOp, MatchesScalar) {
BSONObj operand = BSON("a" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a", operand["a"]);
ASSERT(eq.matchesBSON(BSON("a" << 5.0), NULL));
@@ -111,7 +111,7 @@ TEST(EqOp, MatchesScalar) {
TEST(EqOp, MatchesArrayValue) {
BSONObj operand = BSON("a" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a", operand["a"]);
ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(5.0 << 6)), NULL));
@@ -120,7 +120,7 @@ TEST(EqOp, MatchesArrayValue) {
TEST(EqOp, MatchesReferencedObjectValue) {
BSONObj operand = BSON("a.b" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a.b", operand["a.b"]);
ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << 5)), NULL));
@@ -130,7 +130,7 @@ TEST(EqOp, MatchesReferencedObjectValue) {
TEST(EqOp, MatchesReferencedArrayValue) {
BSONObj operand = BSON("a.0" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a.0", operand["a.0"]);
ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(5)), NULL));
@@ -139,7 +139,7 @@ TEST(EqOp, MatchesReferencedArrayValue) {
TEST(EqOp, MatchesNull) {
BSONObj operand = BSON("a" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a", operand["a"]);
ASSERT(eq.matchesBSON(BSONObj(), NULL));
@@ -153,7 +153,7 @@ TEST(EqOp, MatchesNull) {
// not necessarily how it should work ideally.
TEST(EqOp, MatchesNestedNull) {
BSONObj operand = BSON("a.b" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a.b", operand["a.b"]);
// null matches any empty object that is on a subpath of a.b
@@ -174,7 +174,7 @@ TEST(EqOp, MatchesNestedNull) {
TEST(EqOp, MatchesMinKey) {
BSONObj operand = BSON("a" << MinKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a", operand["a"]);
ASSERT(eq.matchesBSON(BSON("a" << MinKey), NULL));
@@ -185,7 +185,7 @@ TEST(EqOp, MatchesMinKey) {
TEST(EqOp, MatchesMaxKey) {
BSONObj operand = BSON("a" << MaxKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
ASSERT(eq.init("a", operand["a"]).isOK());
ASSERT(eq.matchesBSON(BSON("a" << MaxKey), NULL));
@@ -195,7 +195,7 @@ TEST(EqOp, MatchesMaxKey) {
TEST(EqOp, MatchesFullArray) {
BSONObj operand = BSON("a" << BSON_ARRAY(1 << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
ASSERT(eq.init("a", operand["a"]).isOK());
ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), NULL));
@@ -206,7 +206,7 @@ TEST(EqOp, MatchesFullArray) {
TEST(EqOp, MatchesThroughNestedArray) {
BSONObj operand = BSON("a.b.c.d" << 3);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
eq.init("a.b.c.d", operand["a.b.c.d"]);
BSONObj obj = fromjson("{a:{b:[{c:[{d:1},{d:2}]},{c:[{d:3}]}]}}");
@@ -215,7 +215,7 @@ TEST(EqOp, MatchesThroughNestedArray) {
TEST(EqOp, ElemMatchKey) {
BSONObj operand = BSON("a" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
ASSERT(eq.init("a", operand["a"]).isOK());
MatchDetails details;
@@ -235,7 +235,7 @@ TEST(EqOp, ElemMatchKey) {
TEST(EqOp, ElemMatchKeyWithImplicitAndExplicitTraversal) {
BSONObj operand = BSON("a.0.b" << 3);
BSONElement operandFirstElt = operand.firstElement();
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq(collator);
ASSERT(eq.init(operandFirstElt.fieldName(), operandFirstElt).isOK());
MatchDetails details;
@@ -247,7 +247,7 @@ TEST(EqOp, ElemMatchKeyWithImplicitAndExplicitTraversal) {
}
TEST(EqOp, Equality1) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression eq1(collator);
EqualityMatchExpression eq2(collator);
EqualityMatchExpression eq3(collator);
@@ -320,7 +320,7 @@ TEST(LtOp, MatchesElement) {
BSONObj notMatchEqual = BSON("a" << 5);
BSONObj notMatchWrongType = BSON("a"
<< "foo");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("", operand["$lt"]).isOK());
ASSERT(lt.matchesSingleElement(match.firstElement()));
@@ -331,14 +331,14 @@ TEST(LtOp, MatchesElement) {
TEST(LtOp, InvalidEooOperand) {
BSONObj operand;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(!lt.init("", operand.firstElement()).isOK());
}
TEST(LtOp, MatchesScalar) {
BSONObj operand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["$lt"]).isOK());
ASSERT(lt.matchesBSON(BSON("a" << 4.5), NULL));
@@ -347,7 +347,7 @@ TEST(LtOp, MatchesScalar) {
TEST(LtOp, MatchesScalarEmptyKey) {
BSONObj operand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("", operand["$lt"]).isOK());
ASSERT(lt.matchesBSON(BSON("" << 4.5), NULL));
@@ -356,7 +356,7 @@ TEST(LtOp, MatchesScalarEmptyKey) {
TEST(LtOp, MatchesArrayValue) {
BSONObj operand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["$lt"]).isOK());
ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(6 << 4.5)), NULL));
@@ -365,7 +365,7 @@ TEST(LtOp, MatchesArrayValue) {
TEST(LtOp, MatchesWholeArray) {
BSONObj operand = BSON("$lt" << BSON_ARRAY(5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["$lt"]).isOK());
ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
@@ -379,7 +379,7 @@ TEST(LtOp, MatchesWholeArray) {
TEST(LtOp, MatchesNull) {
BSONObj operand = BSON("$lt" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["$lt"]).isOK());
ASSERT(!lt.matchesBSON(BSONObj(), NULL));
@@ -391,7 +391,7 @@ TEST(LtOp, MatchesNull) {
TEST(LtOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$lt" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a.b", operand["$lt"]).isOK());
ASSERT(!lt.matchesBSON(BSONObj(), NULL));
@@ -406,7 +406,7 @@ TEST(LtOp, MatchesDotNotationNull) {
TEST(LtOp, MatchesMinKey) {
BSONObj operand = BSON("a" << MinKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["a"]).isOK());
ASSERT(!lt.matchesBSON(BSON("a" << MinKey), NULL));
@@ -416,7 +416,7 @@ TEST(LtOp, MatchesMinKey) {
TEST(LtOp, MatchesMaxKey) {
BSONObj operand = BSON("a" << MaxKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["a"]).isOK());
ASSERT(!lt.matchesBSON(BSON("a" << MaxKey), NULL));
@@ -426,7 +426,7 @@ TEST(LtOp, MatchesMaxKey) {
TEST(LtOp, ElemMatchKey) {
BSONObj operand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression lt(collator);
ASSERT(lt.init("a", operand["$lt"]).isOK());
MatchDetails details;
@@ -497,7 +497,7 @@ TEST(LteOp, MatchesElement) {
BSONObj notMatch = BSON("a" << 6);
BSONObj notMatchWrongType = BSON("a"
<< "foo");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("", operand["$lte"]).isOK());
ASSERT(lte.matchesSingleElement(match.firstElement()));
@@ -508,14 +508,14 @@ TEST(LteOp, MatchesElement) {
TEST(LteOp, InvalidEooOperand) {
BSONObj operand;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(!lte.init("", operand.firstElement()).isOK());
}
TEST(LteOp, MatchesScalar) {
BSONObj operand = BSON("$lte" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["$lte"]).isOK());
ASSERT(lte.matchesBSON(BSON("a" << 4.5), NULL));
@@ -524,7 +524,7 @@ TEST(LteOp, MatchesScalar) {
TEST(LteOp, MatchesArrayValue) {
BSONObj operand = BSON("$lte" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["$lte"]).isOK());
ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(6 << 4.5)), NULL));
@@ -533,7 +533,7 @@ TEST(LteOp, MatchesArrayValue) {
TEST(LteOp, MatchesWholeArray) {
BSONObj operand = BSON("$lte" << BSON_ARRAY(5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["$lte"]).isOK());
ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
@@ -547,7 +547,7 @@ TEST(LteOp, MatchesWholeArray) {
TEST(LteOp, MatchesNull) {
BSONObj operand = BSON("$lte" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["$lte"]).isOK());
ASSERT(lte.matchesBSON(BSONObj(), NULL));
@@ -559,7 +559,7 @@ TEST(LteOp, MatchesNull) {
TEST(LteOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$lte" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a.b", operand["$lte"]).isOK());
ASSERT(lte.matchesBSON(BSONObj(), NULL));
@@ -574,7 +574,7 @@ TEST(LteOp, MatchesDotNotationNull) {
TEST(LteOp, MatchesMinKey) {
BSONObj operand = BSON("a" << MinKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["a"]).isOK());
ASSERT(lte.matchesBSON(BSON("a" << MinKey), NULL));
@@ -584,7 +584,7 @@ TEST(LteOp, MatchesMinKey) {
TEST(LteOp, MatchesMaxKey) {
BSONObj operand = BSON("a" << MaxKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["a"]).isOK());
ASSERT(lte.matchesBSON(BSON("a" << MaxKey), NULL));
@@ -595,7 +595,7 @@ TEST(LteOp, MatchesMaxKey) {
TEST(LteOp, ElemMatchKey) {
BSONObj operand = BSON("$lte" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression lte(collator);
ASSERT(lte.init("a", operand["$lte"]).isOK());
MatchDetails details;
@@ -676,14 +676,14 @@ TEST(LteOp, ElemMatchKey) {
TEST(GtOp, InvalidEooOperand) {
BSONObj operand;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(!gt.init("", operand.firstElement()).isOK());
}
TEST(GtOp, MatchesScalar) {
BSONObj operand = BSON("$gt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["$gt"]).isOK());
ASSERT(gt.matchesBSON(BSON("a" << 5.5), NULL));
@@ -692,7 +692,7 @@ TEST(GtOp, MatchesScalar) {
TEST(GtOp, MatchesArrayValue) {
BSONObj operand = BSON("$gt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["$gt"]).isOK());
ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(3 << 5.5)), NULL));
@@ -701,7 +701,7 @@ TEST(GtOp, MatchesArrayValue) {
TEST(GtOp, MatchesWholeArray) {
BSONObj operand = BSON("$gt" << BSON_ARRAY(5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["$gt"]).isOK());
ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
@@ -717,7 +717,7 @@ TEST(GtOp, MatchesWholeArray) {
TEST(GtOp, MatchesNull) {
BSONObj operand = BSON("$gt" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["$gt"]).isOK());
ASSERT(!gt.matchesBSON(BSONObj(), NULL));
@@ -729,7 +729,7 @@ TEST(GtOp, MatchesNull) {
TEST(GtOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$gt" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a.b", operand["$gt"]).isOK());
ASSERT(!gt.matchesBSON(BSONObj(), NULL));
@@ -744,7 +744,7 @@ TEST(GtOp, MatchesDotNotationNull) {
TEST(GtOp, MatchesMinKey) {
BSONObj operand = BSON("a" << MinKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["a"]).isOK());
ASSERT(!gt.matchesBSON(BSON("a" << MinKey), NULL));
@@ -754,7 +754,7 @@ TEST(GtOp, MatchesMinKey) {
TEST(GtOp, MatchesMaxKey) {
BSONObj operand = BSON("a" << MaxKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["a"]).isOK());
ASSERT(!gt.matchesBSON(BSON("a" << MaxKey), NULL));
@@ -764,7 +764,7 @@ TEST(GtOp, MatchesMaxKey) {
TEST(GtOp, ElemMatchKey) {
BSONObj operand = BSON("$gt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression gt(collator);
ASSERT(gt.init("a", operand["$gt"]).isOK());
MatchDetails details;
@@ -836,7 +836,7 @@ TEST(GteOp, MatchesElement) {
BSONObj notMatch = BSON("a" << 4);
BSONObj notMatchWrongType = BSON("a"
<< "foo");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("", operand["$gte"]).isOK());
ASSERT(gte.matchesSingleElement(match.firstElement()));
@@ -847,14 +847,14 @@ TEST(GteOp, MatchesElement) {
TEST(GteOp, InvalidEooOperand) {
BSONObj operand;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(!gte.init("", operand.firstElement()).isOK());
}
TEST(GteOp, MatchesScalar) {
BSONObj operand = BSON("$gte" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["$gte"]).isOK());
ASSERT(gte.matchesBSON(BSON("a" << 5.5), NULL));
@@ -863,7 +863,7 @@ TEST(GteOp, MatchesScalar) {
TEST(GteOp, MatchesArrayValue) {
BSONObj operand = BSON("$gte" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["$gte"]).isOK());
ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), NULL));
@@ -872,7 +872,7 @@ TEST(GteOp, MatchesArrayValue) {
TEST(GteOp, MatchesWholeArray) {
BSONObj operand = BSON("$gte" << BSON_ARRAY(5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["$gte"]).isOK());
ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
@@ -887,7 +887,7 @@ TEST(GteOp, MatchesWholeArray) {
TEST(GteOp, MatchesNull) {
BSONObj operand = BSON("$gte" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["$gte"]).isOK());
ASSERT(gte.matchesBSON(BSONObj(), NULL));
@@ -899,7 +899,7 @@ TEST(GteOp, MatchesNull) {
TEST(GteOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$gte" << BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a.b", operand["$gte"]).isOK());
ASSERT(gte.matchesBSON(BSONObj(), NULL));
@@ -914,7 +914,7 @@ TEST(GteOp, MatchesDotNotationNull) {
TEST(GteOp, MatchesMinKey) {
BSONObj operand = BSON("a" << MinKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["a"]).isOK());
ASSERT(gte.matchesBSON(BSON("a" << MinKey), NULL));
@@ -924,7 +924,7 @@ TEST(GteOp, MatchesMinKey) {
TEST(GteOp, MatchesMaxKey) {
BSONObj operand = BSON("a" << MaxKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["a"]).isOK());
ASSERT(gte.matchesBSON(BSON("a" << MaxKey), NULL));
@@ -934,7 +934,7 @@ TEST(GteOp, MatchesMaxKey) {
TEST(GteOp, ElemMatchKey) {
BSONObj operand = BSON("$gte" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression gte(collator);
ASSERT(gte.init("a", operand["$gte"]).isOK());
MatchDetails details;
@@ -1551,7 +1551,7 @@ TEST(InMatchExpression, MatchesElementSingle) {
BSONArray operand = BSON_ARRAY(1);
BSONObj match = BSON("a" << 1);
BSONObj notMatch = BSON("a" << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.getArrayFilterEntries()->addEquality(operand.firstElement());
ASSERT(in.matchesSingleElement(match["a"]));
@@ -1559,7 +1559,7 @@ TEST(InMatchExpression, MatchesElementSingle) {
}
TEST(InMatchExpression, MatchesEmpty) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
@@ -1571,7 +1571,7 @@ TEST(InMatchExpression, MatchesEmpty) {
TEST(InMatchExpression, MatchesElementMultiple) {
BSONObj operand = BSON_ARRAY(1 << "r" << true << 1);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.getArrayFilterEntries()->addEquality(operand[0]);
in.getArrayFilterEntries()->addEquality(operand[1]);
@@ -1592,7 +1592,7 @@ TEST(InMatchExpression, MatchesElementMultiple) {
TEST(InMatchExpression, MatchesScalar) {
BSONObj operand = BSON_ARRAY(5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand.firstElement());
@@ -1603,7 +1603,7 @@ TEST(InMatchExpression, MatchesScalar) {
TEST(InMatchExpression, MatchesArrayValue) {
BSONObj operand = BSON_ARRAY(5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand.firstElement());
@@ -1616,7 +1616,7 @@ TEST(InMatchExpression, MatchesArrayValue) {
TEST(InMatchExpression, MatchesNull) {
BSONObj operand = BSON_ARRAY(BSONNULL);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand.firstElement());
@@ -1631,7 +1631,7 @@ TEST(InMatchExpression, MatchesNull) {
TEST(InMatchExpression, MatchesUndefined) {
BSONObj operand = BSON_ARRAY(BSONUndefined);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
Status s = in.getArrayFilterEntries()->addEquality(operand.firstElement());
@@ -1640,7 +1640,7 @@ TEST(InMatchExpression, MatchesUndefined) {
TEST(InMatchExpression, MatchesMinKey) {
BSONObj operand = BSON_ARRAY(MinKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand.firstElement());
@@ -1652,7 +1652,7 @@ TEST(InMatchExpression, MatchesMinKey) {
TEST(InMatchExpression, MatchesMaxKey) {
BSONObj operand = BSON_ARRAY(MaxKey);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand.firstElement());
@@ -1664,7 +1664,7 @@ TEST(InMatchExpression, MatchesMaxKey) {
TEST(InMatchExpression, MatchesFullArray) {
BSONObj operand = BSON_ARRAY(BSON_ARRAY(1 << 2) << 4 << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand[0]);
@@ -1679,7 +1679,7 @@ TEST(InMatchExpression, MatchesFullArray) {
TEST(InMatchExpression, ElemMatchKey) {
BSONObj operand = BSON_ARRAY(5 << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.init("a");
in.getArrayFilterEntries()->addEquality(operand[0]);
@@ -1716,7 +1716,7 @@ TEST(InMatchExpression, StringMatchingWithNullCollatorUsesBinaryComparison) {
BSONArray operand = BSON_ARRAY("string");
BSONObj notMatch = BSON("a"
<< "string2");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
InMatchExpression in(collator);
in.getArrayFilterEntries()->addEquality(operand.firstElement());
ASSERT(!in.matchesSingleElement(notMatch["a"]));
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp
index a650ff2e88d..0c9e0187936 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -348,7 +348,7 @@ StatusWithMatchExpression MatchExpressionParser::_parse(const BSONObj& obj, int
mongoutils::str::equals("id", rest) || mongoutils::str::equals("db", rest)) {
// DBRef fields.
// 'id' is collation-aware. 'ref' and 'db' are compared using binary comparison.
- CollatorInterface* collator = (str::equals("id", rest) ? _collator : nullptr);
+ const CollatorInterface* collator = (str::equals("id", rest) ? _collator : nullptr);
std::unique_ptr<ComparisonMatchExpression> eq =
stdx::make_unique<EqualityMatchExpression>(collator);
Status s = eq->init(e.fieldName(), e);
diff --git a/src/mongo/db/matcher/expression_parser.h b/src/mongo/db/matcher/expression_parser.h
index 0bde5027338..61a712b7d92 100644
--- a/src/mongo/db/matcher/expression_parser.h
+++ b/src/mongo/db/matcher/expression_parser.h
@@ -52,13 +52,14 @@ public:
*/
static StatusWithMatchExpression parse(const BSONObj& obj,
const ExtensionsCallback& extensionsCallback,
- CollatorInterface* collator) {
+ const CollatorInterface* collator) {
// The 0 initializes the match expression tree depth.
return MatchExpressionParser(&extensionsCallback, collator)._parse(obj, 0);
}
private:
- MatchExpressionParser(const ExtensionsCallback* extensionsCallback, CollatorInterface* collator)
+ MatchExpressionParser(const ExtensionsCallback* extensionsCallback,
+ const CollatorInterface* collator)
: _extensionsCallback(extensionsCallback), _collator(collator) {}
/**
@@ -155,7 +156,7 @@ private:
// Collator that constructed collation-aware MatchExpressions will use.
// We do not own this pointer - it has to live as long as the parser is active.
- CollatorInterface* _collator;
+ const CollatorInterface* _collator;
};
typedef stdx::function<StatusWithMatchExpression(
diff --git a/src/mongo/db/matcher/expression_parser_array_test.cpp b/src/mongo/db/matcher/expression_parser_array_test.cpp
index c215ea33c9b..e37f6e8adc6 100644
--- a/src/mongo/db/matcher/expression_parser_array_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_array_test.cpp
@@ -47,7 +47,7 @@ using std::string;
TEST(MatchExpressionParserArrayTest, Size1) {
BSONObj query = BSON("x" << BSON("$size" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -60,7 +60,7 @@ TEST(MatchExpressionParserArrayTest, Size1) {
TEST(MatchExpressionParserArrayTest, SizeAsLong) {
BSONObj query = BSON("x" << BSON("$size" << 2LL));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -73,7 +73,7 @@ TEST(MatchExpressionParserArrayTest, SizeAsLong) {
TEST(MatchExpressionParserArrayTest, SizeAsNegativeLong) {
BSONObj query = BSON("x" << BSON("$size" << -2LL));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -81,7 +81,7 @@ TEST(MatchExpressionParserArrayTest, SizeAsNegativeLong) {
TEST(MatchExpressionParserArrayTest, SizeTooLarge) {
BSONObj query = BSON("x" << BSON("$size" << std::numeric_limits<long long>::max()));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -90,7 +90,7 @@ TEST(MatchExpressionParserArrayTest, SizeTooLarge) {
TEST(MatchExpressionParserArrayTest, SizeAsString) {
BSONObj query = BSON("x" << BSON("$size"
<< "a"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -98,7 +98,7 @@ TEST(MatchExpressionParserArrayTest, SizeAsString) {
TEST(MatchExpressionParserArrayTest, SizeWithIntegralDouble) {
BSONObj query = BSON("x" << BSON("$size" << 2.0));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -111,7 +111,7 @@ TEST(MatchExpressionParserArrayTest, SizeWithIntegralDouble) {
TEST(MatchExpressionParserArrayTest, SizeWithNegativeIntegralDouble) {
BSONObj query = BSON("x" << BSON("$size" << -2.0));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -119,7 +119,7 @@ TEST(MatchExpressionParserArrayTest, SizeWithNegativeIntegralDouble) {
TEST(MatchExpressionParserArrayTest, SizeWithDouble) {
BSONObj query = BSON("x" << BSON("$size" << 2.5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -127,7 +127,7 @@ TEST(MatchExpressionParserArrayTest, SizeWithDouble) {
TEST(MatchExpressionParserArrayTest, SizeWithNegative) {
BSONObj query = BSON("x" << BSON("$size" << -2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -135,7 +135,7 @@ TEST(MatchExpressionParserArrayTest, SizeWithNegative) {
TEST(MatchExpressionParserArrayTest, SizeBad) {
BSONObj query = BSON("x" << BSON("$size" << BSONNULL));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -145,7 +145,7 @@ TEST(MatchExpressionParserArrayTest, SizeBad) {
TEST(MatchExpressionParserArrayTest, ElemMatchArr1) {
BSONObj query = BSON("x" << BSON("$elemMatch" << BSON("x" << 1 << "y" << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -159,7 +159,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchArr1) {
TEST(MatchExpressionParserArrayTest, ElemMatchAnd) {
BSONObj query =
BSON("x" << BSON("$elemMatch" << BSON("$and" << BSON_ARRAY(BSON("x" << 1 << "y" << 2)))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -172,7 +172,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchAnd) {
TEST(MatchExpressionParserArrayTest, ElemMatchNor) {
BSONObj query = BSON("x" << BSON("$elemMatch" << BSON("$nor" << BSON_ARRAY(BSON("x" << 1)))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -186,7 +186,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchNor) {
TEST(MatchExpressionParserArrayTest, ElemMatchOr) {
BSONObj query =
BSON("x" << BSON("$elemMatch" << BSON("$or" << BSON_ARRAY(BSON("x" << 1 << "y" << 2)))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -199,7 +199,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchOr) {
TEST(MatchExpressionParserArrayTest, ElemMatchVal1) {
BSONObj query = BSON("x" << BSON("$elemMatch" << BSON("$gt" << 5)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -223,7 +223,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef1) {
<< "db");
BSONObj query = BSON("x" << BSON("$elemMatch" << BSON("$eq" << match)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -246,7 +246,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef2) {
<< "db");
BSONObj query = BSON("x" << BSON("$elemMatch" << match));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -268,7 +268,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef3) {
<< "$id" << oidx << "foo" << 12345);
BSONObj query = BSON("x" << BSON("$elemMatch" << match));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -302,7 +302,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef4) {
<< "db");
BSONObj query = BSON("x" << BSON("$elemMatch" << matchOutOfOrder));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -327,7 +327,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef5) {
<< "$id" << oidx << "foo" << 12345);
BSONObj query = BSON("x" << BSON("$elemMatch" << matchOutOfOrder));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -357,7 +357,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef6) {
<< "$id" << oid << "foo" << 12345);
BSONObj query = BSON("x" << BSON("$elemMatch" << matchMissingID));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -386,7 +386,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef7) {
<< "$id" << oidx << "foo" << 12345);
BSONObj query = BSON("x" << BSON("$elemMatch" << matchMissingRef));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -420,7 +420,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef8) {
<< "foo" << 12345);
BSONObj query = BSON("x" << BSON("$elemMatch" << matchDBOnly));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -440,7 +440,7 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef8) {
TEST(MatchExpressionParserArrayTest, All1) {
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY(1 << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -458,7 +458,7 @@ TEST(MatchExpressionParserArrayTest, All1) {
TEST(MatchExpressionParserArrayTest, AllNull) {
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY(BSONNULL)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -474,7 +474,7 @@ TEST(MatchExpressionParserArrayTest, AllNull) {
TEST(MatchExpressionParserArrayTest, AllBadArg) {
BSONObj query = BSON("x" << BSON("$all" << 1));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -489,7 +489,7 @@ TEST(MatchExpressionParserArrayTest, AllBadRegexArg) {
BSONObj query = BSON("x" << operand.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -504,7 +504,7 @@ TEST(MatchExpressionParserArrayTest, AllRegex1) {
all.appendArray("$all", allArray.obj());
BSONObj query = BSON("a" << all.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -532,7 +532,7 @@ TEST(MatchExpressionParserArrayTest, AllRegex2) {
all.appendArray("$all", allArray.obj());
BSONObj query = BSON("a" << all.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -551,7 +551,7 @@ TEST(MatchExpressionParserArrayTest, AllRegex2) {
TEST(MatchExpressionParserArrayTest, AllNonArray) {
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY(5)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -569,7 +569,7 @@ TEST(MatchExpressionParserArrayTest, AllNonArray) {
TEST(MatchExpressionParserArrayTest, AllElemMatch1) {
BSONObj internal = BSON("x" << 1 << "y" << 2);
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY(BSON("$elemMatch" << internal))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -591,7 +591,7 @@ TEST(MatchExpressionParserArrayTest, AllElemMatch1) {
TEST(MatchExpressionParserArrayTest, AllElemMatch2) {
BSONObj internal = BSON("z" << 1);
BSONObj query = BSON("x.y" << BSON("$all" << BSON_ARRAY(BSON("$elemMatch" << internal))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -628,7 +628,7 @@ TEST(MatchExpressionParserArrayTest, AllElemMatch2) {
// are correct.
TEST(MatchExpressionParserArrayTest, AllElemMatch3) {
BSONObj query = fromjson("{x: {$all: [{$elemMatch: {y: 1, z: 1}}]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -665,7 +665,7 @@ TEST(MatchExpressionParserArrayTest, AllElemMatchBad) {
BSONObj internal = BSON("x" << 1 << "y" << 2);
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY(BSON("$elemMatch" << internal) << 5)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -679,7 +679,7 @@ TEST(MatchExpressionParserArrayTest, AllElemMatchBad) {
TEST(MatchExpressionParserArrayTest, AllElemMatchBadMixed) {
// $elemMatch first, equality second.
BSONObj bad1 = fromjson("{x: {$all: [{$elemMatch: {y: 1}}, 3]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result1 =
MatchExpressionParser::parse(bad1, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result1.isOK());
@@ -706,7 +706,7 @@ TEST(MatchExpressionParserArrayTest, AllElemMatchBadMixed) {
// $all with empty string.
TEST(MatchExpressionParserArrayTest, AllEmptyString) {
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY("")));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -732,7 +732,7 @@ TEST(MatchExpressionParserArrayTest, AllISODate) {
const Date_t& notMatch = notMatchResult.getValue();
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY(match)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -749,7 +749,7 @@ TEST(MatchExpressionParserArrayTest, AllISODate) {
// $all on array element with empty string.
TEST(MatchExpressionParserArrayTest, AllDottedEmptyString) {
BSONObj query = BSON("x.1" << BSON("$all" << BSON_ARRAY("")));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -777,7 +777,7 @@ TEST(MatchExpressionParserArrayTest, AllDottedISODate) {
const Date_t& notMatch = notMatchResult.getValue();
BSONObj query = BSON("x.1" << BSON("$all" << BSON_ARRAY(match)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -795,7 +795,7 @@ TEST(MatchExpressionParserArrayTest, AllDottedISODate) {
TEST(MatchExpressionParserArrayTest, AllStringNullCollation) {
BSONObj query = BSON("x" << BSON("$all" << BSON_ARRAY("string")));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
diff --git a/src/mongo/db/matcher/expression_parser_geo_test.cpp b/src/mongo/db/matcher/expression_parser_geo_test.cpp
index 5724cff0d51..b4450c41785 100644
--- a/src/mongo/db/matcher/expression_parser_geo_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_geo_test.cpp
@@ -43,7 +43,7 @@ namespace mongo {
TEST(MatchExpressionParserGeo, WithinBox) {
BSONObj query = fromjson("{a:{$within:{$box:[{x: 4, y:4},[6,6]]}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -60,7 +60,7 @@ TEST(MatchExpressionParserGeoNear, ParseNear) {
"{loc:{$near:{$maxDistance:100, "
"$geometry:{type:\"Point\", coordinates:[0,0]}}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -78,7 +78,7 @@ TEST(MatchExpressionParserGeoNear, ParseNearExtraField) {
"{loc:{$near:{$maxDistance:100, "
"$geometry:{type:\"Point\", coordinates:[0,0]}}, foo: 1}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
@@ -93,7 +93,7 @@ TEST(MatchExpressionParserGeoNear, ParseNearExtraField) {
TEST(MatchExpressionParserGeoNear, ParseValidNear) {
BSONObj query = fromjson("{loc: {$near: [0,0], $maxDistance: 100, $minDistance: 50}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -109,42 +109,42 @@ TEST(MatchExpressionParserGeoNear, ParseValidNear) {
TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
{
BSONObj query = fromjson("{loc: {$maxDistance: 100, $near: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$minDistance: 100, $near: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$near: [0,0], $maxDistance: {}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$near: [0,0], $minDistance: {}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$near: [0,0], $eq: 40}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$eq: 40, $near: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -152,21 +152,21 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
{
BSONObj query = fromjson(
"{loc: {$near: [0,0], $geoWithin: {$geometry: {type: \"Polygon\", coordinates: []}}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$near: {$foo: 1}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$minDistance: 10}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -176,7 +176,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidNear) {
TEST(MatchExpressionParserGeoNear, ParseValidGeoNear) {
BSONObj query = fromjson("{loc: {$geoNear: [0,0], $maxDistance: 100, $minDistance: 50}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -192,35 +192,35 @@ TEST(MatchExpressionParserGeoNear, ParseValidGeoNear) {
TEST(MatchExpressionParserGeoNear, ParseInvalidGeoNear) {
{
BSONObj query = fromjson("{loc: {$maxDistance: 100, $geoNear: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$minDistance: 100, $geoNear: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$geoNear: [0,0], $eq: 1}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$geoNear: [0,0], $maxDistance: {}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$geoNear: [0,0], $minDistance: {}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
@@ -230,7 +230,7 @@ TEST(MatchExpressionParserGeoNear, ParseInvalidGeoNear) {
TEST(MatchExpressionParserGeoNear, ParseValidNearSphere) {
BSONObj query = fromjson("{loc: {$nearSphere: [0,0], $maxDistance: 100, $minDistance: 50}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -246,35 +246,35 @@ TEST(MatchExpressionParserGeoNear, ParseValidNearSphere) {
TEST(MatchExpressionParserGeoNear, ParseInvalidNearSphere) {
{
BSONObj query = fromjson("{loc: {$maxDistance: 100, $nearSphere: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$minDistance: 100, $nearSphere: [0,0]}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
{
BSONObj query = fromjson("{loc: {$nearSphere: [0,0], $maxDistance: {}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$nearSphere: [0,0], $minDistance: {}}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
}
{
BSONObj query = fromjson("{loc: {$nearSphere: [0,0], $eq: 1}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_THROWS(
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator),
UserException);
diff --git a/src/mongo/db/matcher/expression_parser_leaf_test.cpp b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
index b3a3639defd..a6836126ef4 100644
--- a/src/mongo/db/matcher/expression_parser_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
@@ -51,7 +51,7 @@ using std::string;
TEST(MatchExpressionParserLeafTest, NullCollation) {
BSONObj query = BSON("x"
<< "string");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -75,7 +75,7 @@ TEST(MatchExpressionParserLeafTest, Collation) {
TEST(MatchExpressionParserLeafTest, SimpleEQ2) {
BSONObj query = BSON("x" << BSON("$eq" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -87,7 +87,7 @@ TEST(MatchExpressionParserLeafTest, SimpleEQ2) {
TEST(MatchExpressionParserLeafTest, SimpleEQUndefined) {
BSONObj query = BSON("x" << BSON("$eq" << BSONUndefined));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -96,7 +96,7 @@ TEST(MatchExpressionParserLeafTest, SimpleEQUndefined) {
TEST(MatchExpressionParserLeafTest, EQNullCollation) {
BSONObj query = BSON("x" << BSON("$eq"
<< "string"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -120,7 +120,7 @@ TEST(MatchExpressionParserLeafTest, EQCollation) {
TEST(MatchExpressionParserLeafTest, SimpleGT1) {
BSONObj query = BSON("x" << BSON("$gt" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -132,7 +132,7 @@ TEST(MatchExpressionParserLeafTest, SimpleGT1) {
TEST(MatchExpressionParserLeafTest, GTNullCollation) {
BSONObj query = BSON("x" << BSON("$gt"
<< "abc"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -156,7 +156,7 @@ TEST(MatchExpressionParserLeafTest, GTCollation) {
TEST(MatchExpressionParserLeafTest, SimpleLT1) {
BSONObj query = BSON("x" << BSON("$lt" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -169,7 +169,7 @@ TEST(MatchExpressionParserLeafTest, SimpleLT1) {
TEST(MatchExpressionParserLeafTest, LTNullCollation) {
BSONObj query = BSON("x" << BSON("$lt"
<< "abc"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -193,7 +193,7 @@ TEST(MatchExpressionParserLeafTest, LTCollation) {
TEST(MatchExpressionParserLeafTest, SimpleGTE1) {
BSONObj query = BSON("x" << BSON("$gte" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -206,7 +206,7 @@ TEST(MatchExpressionParserLeafTest, SimpleGTE1) {
TEST(MatchExpressionParserLeafTest, GTENullCollation) {
BSONObj query = BSON("x" << BSON("$gte"
<< "abc"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -230,7 +230,7 @@ TEST(MatchExpressionParserLeafTest, GTECollation) {
TEST(MatchExpressionParserLeafTest, SimpleLTE1) {
BSONObj query = BSON("x" << BSON("$lte" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -243,7 +243,7 @@ TEST(MatchExpressionParserLeafTest, SimpleLTE1) {
TEST(MatchExpressionParserLeafTest, LTENullCollation) {
BSONObj query = BSON("x" << BSON("$lte"
<< "abc"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -267,7 +267,7 @@ TEST(MatchExpressionParserLeafTest, LTECollation) {
TEST(MatchExpressionParserLeafTest, SimpleNE1) {
BSONObj query = BSON("x" << BSON("$ne" << 2));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -280,7 +280,7 @@ TEST(MatchExpressionParserLeafTest, SimpleNE1) {
TEST(MatchExpressionParserLeafTest, NENullCollation) {
BSONObj query = BSON("x" << BSON("$ne"
<< "string"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -308,7 +308,7 @@ TEST(MatchExpressionParserLeafTest, NECollation) {
TEST(MatchExpressionParserLeafTest, SimpleModBad1) {
BSONObj query = BSON("x" << BSON("$mod" << BSON_ARRAY(3 << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -336,7 +336,7 @@ TEST(MatchExpressionParserLeafTest, SimpleModBad1) {
TEST(MatchExpressionParserLeafTest, SimpleMod1) {
BSONObj query = BSON("x" << BSON("$mod" << BSON_ARRAY(3 << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -348,7 +348,7 @@ TEST(MatchExpressionParserLeafTest, SimpleMod1) {
TEST(MatchExpressionParserLeafTest, SimpleModNotNumber) {
BSONObj query = BSON("x" << BSON("$mod" << BSON_ARRAY(2 << "r")));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -363,7 +363,7 @@ TEST(MatchExpressionParserLeafTest, SimpleModNotNumber) {
TEST(MatchExpressionParserLeafTest, IdCollation) {
BSONObj query = BSON("$id"
<< "string");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -410,7 +410,7 @@ TEST(MatchExpressionParserLeafTest, DbCollation) {
TEST(MatchExpressionParserLeafTest, SimpleIN1) {
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(2 << 3)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -422,7 +422,7 @@ TEST(MatchExpressionParserLeafTest, SimpleIN1) {
TEST(MatchExpressionParserLeafTest, INNullCollation) {
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY("string")));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -448,7 +448,7 @@ TEST(MatchExpressionParserLeafTest, INSingleDBRef) {
<< "coll"
<< "$id" << oid << "$db"
<< "db"))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -512,7 +512,7 @@ TEST(MatchExpressionParserLeafTest, INMultipleDBRef) {
<< "coll"
<< "$id" << oid << "$db"
<< "db"))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -613,7 +613,7 @@ TEST(MatchExpressionParserLeafTest, INDBRefWithOptionalField1) {
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(BSON("$ref"
<< "coll"
<< "$id" << oid << "foo" << 12345))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -640,7 +640,7 @@ TEST(MatchExpressionParserLeafTest, INInvalidDBRefs) {
// missing $id
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(BSON("$ref"
<< "coll"))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
result = MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
@@ -669,7 +669,7 @@ TEST(MatchExpressionParserLeafTest, INInvalidDBRefs) {
TEST(MatchExpressionParserLeafTest, INExpressionDocument) {
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(BSON("$foo" << 1))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -677,7 +677,7 @@ TEST(MatchExpressionParserLeafTest, INExpressionDocument) {
TEST(MatchExpressionParserLeafTest, INNotArray) {
BSONObj query = BSON("x" << BSON("$in" << 5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -685,7 +685,7 @@ TEST(MatchExpressionParserLeafTest, INNotArray) {
TEST(MatchExpressionParserLeafTest, INUndefined) {
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(BSONUndefined)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -693,7 +693,7 @@ TEST(MatchExpressionParserLeafTest, INUndefined) {
TEST(MatchExpressionParserLeafTest, INNotElemMatch) {
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(BSON("$elemMatch" << 1))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -706,7 +706,7 @@ TEST(MatchExpressionParserLeafTest, INRegexTooLong) {
BSONObjBuilder operand;
operand.appendArray("$in", inArray.obj());
BSONObj query = BSON("x" << operand.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -715,7 +715,7 @@ TEST(MatchExpressionParserLeafTest, INRegexTooLong) {
TEST(MatchExpressionParserLeafTest, INRegexTooLong2) {
string tooLargePattern(50 * 1000, 'z');
BSONObj query = BSON("x" << BSON("$in" << BSON_ARRAY(BSON("$regex" << tooLargePattern))));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -730,7 +730,7 @@ TEST(MatchExpressionParserLeafTest, INRegexStuff) {
operand.appendArray("$in", inArray.obj());
BSONObj query = BSON("a" << operand.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -757,7 +757,7 @@ TEST(MatchExpressionParserLeafTest, INRegexStuff) {
TEST(MatchExpressionParserLeafTest, SimpleNIN1) {
BSONObj query = BSON("x" << BSON("$nin" << BSON_ARRAY(2 << 3)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -769,7 +769,7 @@ TEST(MatchExpressionParserLeafTest, SimpleNIN1) {
TEST(MatchExpressionParserLeafTest, NINNotArray) {
BSONObj query = BSON("x" << BSON("$nin" << 5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -777,7 +777,7 @@ TEST(MatchExpressionParserLeafTest, NINNotArray) {
TEST(MatchExpressionParserLeafTest, NINNullCollation) {
BSONObj query = BSON("x" << BSON("$nin" << BSON_ARRAY("string")));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -805,7 +805,7 @@ TEST(MatchExpressionParserLeafTest, Regex1) {
BSONObjBuilder b;
b.appendRegex("x", "abc", "i");
BSONObj query = b.obj();
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -823,7 +823,7 @@ TEST(MatchExpressionParserLeafTest, Regex2) {
<< "abc"
<< "$options"
<< "i"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -841,7 +841,7 @@ TEST(MatchExpressionParserLeafTest, Regex3) {
<< "i"
<< "$regex"
<< "abc"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
log() << "result: " << result.getStatus() << endl;
@@ -861,7 +861,7 @@ TEST(MatchExpressionParserLeafTest, RegexBad) {
<< "abc"
<< "$optionas"
<< "i"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -889,7 +889,7 @@ TEST(MatchExpressionParserLeafTest, RegexBad) {
TEST(MatchExpressionParserLeafTest, RegexEmbeddedNULByte) {
BSONObj query = BSON("x" << BSON("$regex"
<< "^a\\x00b"));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -904,7 +904,7 @@ TEST(MatchExpressionParserLeafTest, ExistsYes1) {
BSONObjBuilder b;
b.appendBool("$exists", true);
BSONObj query = BSON("x" << b.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -919,7 +919,7 @@ TEST(MatchExpressionParserLeafTest, ExistsNO1) {
BSONObjBuilder b;
b.appendBool("$exists", false);
BSONObj query = BSON("x" << b.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -932,7 +932,7 @@ TEST(MatchExpressionParserLeafTest, ExistsNO1) {
TEST(MatchExpressionParserLeafTest, Type1) {
BSONObj query = BSON("x" << BSON("$type" << String));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -944,7 +944,7 @@ TEST(MatchExpressionParserLeafTest, Type1) {
TEST(MatchExpressionParserLeafTest, Type2) {
BSONObj query = BSON("x" << BSON("$type" << (double)NumberDouble));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -955,7 +955,7 @@ TEST(MatchExpressionParserLeafTest, Type2) {
TEST(MatchExpressionParserLeafTest, TypeDoubleOperator) {
BSONObj query = BSON("x" << BSON("$type" << 1.5));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -967,7 +967,7 @@ TEST(MatchExpressionParserLeafTest, TypeDoubleOperator) {
TEST(MatchExpressionParserLeafTest, TypeDecimalOperator) {
if (Decimal128::enabled) {
BSONObj query = BSON("x" << BSON("$type" << mongo::NumberDecimal));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -979,7 +979,7 @@ TEST(MatchExpressionParserLeafTest, TypeDecimalOperator) {
TEST(MatchExpressionParserLeafTest, TypeNull) {
BSONObj query = BSON("x" << BSON("$type" << jstNULL));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -995,7 +995,7 @@ TEST(MatchExpressionParserLeafTest, TypeBadType) {
BSONObjBuilder b;
b.append("$type", (JSTypeMax + 1));
BSONObj query = BSON("x" << b.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_NOT_OK(result.getStatus());
@@ -1003,14 +1003,14 @@ TEST(MatchExpressionParserLeafTest, TypeBadType) {
TEST(MatchExpressionParserLeafTest, TypeBad) {
BSONObj query = BSON("x" << BSON("$type" << BSON("x" << 1)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
}
TEST(MatchExpressionParserLeafTest, TypeBadString) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_NOT_OK(MatchExpressionParser::parse(fromjson("{a: {$type: null}}"),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
@@ -1030,7 +1030,7 @@ TEST(MatchExpressionParserLeafTest, TypeBadString) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameDouble) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumberDouble = MatchExpressionParser::parse(
fromjson("{a: {$type: 'double'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeNumberDouble.getStatus());
@@ -1043,7 +1043,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameDouble) {
TEST(MatchExpressionParserLeafTest, TypeStringNameNumberDecimal) {
if (Decimal128::enabled) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumberDecimal = MatchExpressionParser::parse(
fromjson("{a: {$type: 'decimal'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeNumberDecimal.getStatus());
@@ -1056,7 +1056,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringNameNumberDecimal) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameNumberInt) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumberInt = MatchExpressionParser::parse(
fromjson("{a: {$type: 'int'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeNumberInt.getStatus());
@@ -1068,7 +1068,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameNumberInt) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameNumberLong) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumberLong = MatchExpressionParser::parse(
fromjson("{a: {$type: 'long'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeNumberLong.getStatus());
@@ -1080,7 +1080,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameNumberLong) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameString) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeString = MatchExpressionParser::parse(
fromjson("{a: {$type: 'string'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeString.getStatus());
@@ -1091,7 +1091,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameString) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnamejstOID) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typejstOID = MatchExpressionParser::parse(
fromjson("{a: {$type: 'objectId'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typejstOID.getStatus());
@@ -1102,7 +1102,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnamejstOID) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnamejstNULL) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typejstNULL = MatchExpressionParser::parse(
fromjson("{a: {$type: 'null'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typejstNULL.getStatus());
@@ -1114,7 +1114,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnamejstNULL) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameBool) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeBool = MatchExpressionParser::parse(
fromjson("{a: {$type: 'bool'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeBool.getStatus());
@@ -1125,7 +1125,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameBool) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameObject) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeObject = MatchExpressionParser::parse(
fromjson("{a: {$type: 'object'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeObject.getStatus());
@@ -1136,7 +1136,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameObject) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameArray) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeArray = MatchExpressionParser::parse(
fromjson("{a: {$type: 'array'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeArray.getStatus());
@@ -1147,7 +1147,7 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameArray) {
}
TEST(MatchExpressionParserLeafTest, TypeStringnameNumber) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumber = MatchExpressionParser::parse(
fromjson("{a: {$type: 'number'}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(typeNumber.getStatus());
@@ -1159,21 +1159,21 @@ TEST(MatchExpressionParserLeafTest, TypeStringnameNumber) {
}
TEST(MatchExpressionParserLeafTest, InvalidTypeCodeLessThanMinKeyFailsToParse) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumber = MatchExpressionParser::parse(
fromjson("{a: {$type: -20}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_NOT_OK(typeNumber.getStatus());
}
TEST(MatchExpressionParserLeafTest, InvalidTypeCodeGreaterThanMaxKeyFailsToParse) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumber = MatchExpressionParser::parse(
fromjson("{a: {$type: 400}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_NOT_OK(typeNumber.getStatus());
}
TEST(MatchExpressionParserLeafTest, InvalidTypeCodeUnusedBetweenMinAndMaxFailsToParse) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression typeNumber = MatchExpressionParser::parse(
fromjson("{a: {$type: 62}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_NOT_OK(typeNumber.getStatus());
@@ -1187,7 +1187,7 @@ TEST(MatchExpressionParserLeafTest, ValidTypeCodesParseSuccessfully) {
for (auto type : validTypes) {
BSONObj predicate = BSON("a" << BSON("$type" << type));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
auto expression = MatchExpressionParser::parse(
predicate, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(expression.getStatus());
@@ -1199,7 +1199,7 @@ TEST(MatchExpressionParserLeafTest, ValidTypeCodesParseSuccessfully) {
TEST(MatchExpressionParserTest, BitTestMatchExpressionValidMask) {
const double k2Power53 = scalbn(1, 32);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_OK(MatchExpressionParser::parse(BSON("a" << BSON("$bitsAllSet" << 54)),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
@@ -1264,7 +1264,7 @@ TEST(MatchExpressionParserTest, BitTestMatchExpressionValidArray) {
ASSERT_EQ(BSONType::NumberLong, bsonArrayLongLong[2].type());
ASSERT_EQ(BSONType::NumberLong, bsonArrayLongLong[3].type());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_OK(MatchExpressionParser::parse(BSON("a" << BSON("$bitsAllSet" << BSON_ARRAY(0))),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
@@ -1327,7 +1327,7 @@ TEST(MatchExpressionParserTest, BitTestMatchExpressionValidArray) {
}
TEST(MatchExpressionParserTest, BitTestMatchExpressionValidBinData) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_OK(
MatchExpressionParser::parse(
fromjson("{a: {$bitsAllSet: {$binary: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAA', $type: '00'}}}"),
@@ -1356,7 +1356,7 @@ TEST(MatchExpressionParserTest, BitTestMatchExpressionValidBinData) {
}
TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidMaskType) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_NOT_OK(MatchExpressionParser::parse(fromjson("{a: {$bitsAllSet: null}}"),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
@@ -1425,7 +1425,7 @@ TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidMaskType) {
TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidMaskValue) {
const double kLongLongMaxAsDouble = scalbn(1, std::numeric_limits<long long>::digits);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_NOT_OK(MatchExpressionParser::parse(fromjson("{a: {$bitsAllSet: NaN}}"),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
@@ -1500,7 +1500,7 @@ TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidMaskValue) {
}
TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidArray) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_NOT_OK(MatchExpressionParser::parse(fromjson("{a: {$bitsAllSet: [null]}}"),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
@@ -1615,7 +1615,7 @@ TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidArray) {
}
TEST(MatchExpressionParserTest, BitTestMatchExpressionInvalidArrayValue) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ASSERT_NOT_OK(MatchExpressionParser::parse(fromjson("{a: {$bitsAllSet: [-54]}}"),
ExtensionsCallbackDisallowExtensions(),
collator).getStatus());
diff --git a/src/mongo/db/matcher/expression_parser_test.cpp b/src/mongo/db/matcher/expression_parser_test.cpp
index 35b55c0b9f6..d715bf46cfc 100644
--- a/src/mongo/db/matcher/expression_parser_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_test.cpp
@@ -42,7 +42,7 @@ namespace mongo {
TEST(MatchExpressionParserTest, SimpleEQ1) {
BSONObj query = BSON("x" << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -53,7 +53,7 @@ TEST(MatchExpressionParserTest, SimpleEQ1) {
TEST(MatchExpressionParserTest, Multiple1) {
BSONObj query = BSON("x" << 5 << "y" << BSON("$gt" << 5 << "$lt" << 8));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -67,7 +67,7 @@ TEST(MatchExpressionParserTest, Multiple1) {
TEST(AtomicMatchExpressionTest, AtomicOperator1) {
BSONObj query = BSON("x" << 5 << "$atomic" << BSON("$gt" << 5 << "$lt" << 8));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -83,7 +83,7 @@ TEST(AtomicMatchExpressionTest, AtomicOperator1) {
TEST(MatchExpressionParserTest, MinDistanceWithoutNearFailsToParse) {
BSONObj query = fromjson("{loc: {$minDistance: 10}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
diff --git a/src/mongo/db/matcher/expression_parser_tree_test.cpp b/src/mongo/db/matcher/expression_parser_tree_test.cpp
index 01e52c33841..e3c17b7bc91 100644
--- a/src/mongo/db/matcher/expression_parser_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_tree_test.cpp
@@ -42,7 +42,7 @@ namespace mongo {
TEST(MatchExpressionParserTreeTest, OR1) {
BSONObj query = BSON("$or" << BSON_ARRAY(BSON("x" << 1) << BSON("y" << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -56,7 +56,7 @@ TEST(MatchExpressionParserTreeTest, OR1) {
TEST(MatchExpressionParserTreeTest, OREmbedded) {
BSONObj query1 = BSON("$or" << BSON_ARRAY(BSON("x" << 1) << BSON("y" << 2)));
BSONObj query2 = BSON("$or" << BSON_ARRAY(query1));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query2, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -70,7 +70,7 @@ TEST(MatchExpressionParserTreeTest, OREmbedded) {
TEST(MatchExpressionParserTreeTest, AND1) {
BSONObj query = BSON("$and" << BSON_ARRAY(BSON("x" << 1) << BSON("y" << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -85,7 +85,7 @@ TEST(MatchExpressionParserTreeTest, AND1) {
TEST(MatchExpressionParserTreeTest, NOREmbedded) {
BSONObj query = BSON("$nor" << BSON_ARRAY(BSON("x" << 1) << BSON("y" << 2)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -98,7 +98,7 @@ TEST(MatchExpressionParserTreeTest, NOREmbedded) {
TEST(MatchExpressionParserTreeTest, NOT1) {
BSONObj query = BSON("x" << BSON("$not" << BSON("$gt" << 5)));
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
@@ -121,7 +121,7 @@ TEST(MatchExpressionParserTreeTest, MaximumTreeDepthNotExceed) {
}
BSONObj query = fromjson(ss.str());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(result.isOK());
@@ -141,7 +141,7 @@ TEST(MatchExpressionParserTreeTest, MaximumTreeDepthExceed) {
}
BSONObj query = fromjson(ss.str());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -162,7 +162,7 @@ TEST(MatchExpressionParserTreeTest, MaximumTreeDepthExceededNestedNots) {
}
BSONObj query = fromjson(ss.str());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -182,7 +182,7 @@ TEST(MatchExpressionParserTreeTest, MaximumTreeDepthExceededNestedElemMatch) {
}
BSONObj query = fromjson(ss.str());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_FALSE(result.isOK());
@@ -192,7 +192,7 @@ TEST(MatchExpressionParserLeafTest, NotRegex1) {
BSONObjBuilder b;
b.appendRegex("$not", "abc", "i");
BSONObj query = BSON("x" << b.obj());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression result =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(result.isOK());
diff --git a/src/mongo/db/matcher/expression_serialization_test.cpp b/src/mongo/db/matcher/expression_serialization_test.cpp
index 43f6f6ebf25..3a764e420cd 100644
--- a/src/mongo/db/matcher/expression_serialization_test.cpp
+++ b/src/mongo/db/matcher/expression_serialization_test.cpp
@@ -51,7 +51,7 @@ BSONObj serialize(MatchExpression* match) {
}
TEST(SerializeBasic, AndExpressionWithOneChildSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$and: [{x: 0}]}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -66,7 +66,7 @@ TEST(SerializeBasic, AndExpressionWithOneChildSerializesCorrectly) {
}
TEST(SerializeBasic, AndExpressionWithTwoChildrenSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$and: [{x: 1}, {x: 2}]}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -81,7 +81,7 @@ TEST(SerializeBasic, AndExpressionWithTwoChildrenSerializesCorrectly) {
}
TEST(SerializeBasic, AndExpressionWithTwoIdenticalChildrenSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$and: [{x: 1}, {x: 1}]}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -96,7 +96,7 @@ TEST(SerializeBasic, AndExpressionWithTwoIdenticalChildrenSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionOr) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$or: [{x: 'A'}, {x: 'B'}]}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -111,7 +111,7 @@ TEST(SerializeBasic, ExpressionOr) {
}
TEST(SerializeBasic, ExpressionElemMatchObjectSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$elemMatch: {a: {$gt: 0}, b: {$gt: 0}}}}"),
ExtensionsCallbackNoop(),
collator);
@@ -129,7 +129,7 @@ TEST(SerializeBasic, ExpressionElemMatchObjectSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionElemMatchObjectWithEmptyStringSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{'': {$elemMatch: {a: {$gt: 0}, b: {$gt: 0}}}}"),
ExtensionsCallbackNoop(),
collator);
@@ -147,7 +147,7 @@ TEST(SerializeBasic, ExpressionElemMatchObjectWithEmptyStringSerializesCorrectly
}
TEST(SerializeBasic, ExpressionElemMatchValueSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson("{x: {$elemMatch: {$lt: 1, $gt: -1}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
@@ -166,7 +166,7 @@ TEST(SerializeBasic, ExpressionElemMatchValueSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionElemMatchValueWithEmptyStringSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson("{x: {$elemMatch: {$lt: 1, $gt: -1}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
@@ -185,7 +185,7 @@ TEST(SerializeBasic, ExpressionElemMatchValueWithEmptyStringSerializesCorrectly)
}
TEST(SerializeBasic, ExpressionSizeSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$size: 2}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -200,7 +200,7 @@ TEST(SerializeBasic, ExpressionSizeSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionAllSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$all: [1, 2]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -215,7 +215,7 @@ TEST(SerializeBasic, ExpressionAllSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionAllWithEmptyArraySerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$all: []}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -227,7 +227,7 @@ TEST(SerializeBasic, ExpressionAllWithEmptyArraySerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionAllWithRegex) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson("{x: {$all: [/a.b.c/, /.d.e./]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
@@ -243,7 +243,7 @@ TEST(SerializeBasic, ExpressionAllWithRegex) {
}
TEST(SerializeBasic, ExpressionEqSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$eq: {a: 1}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -261,7 +261,7 @@ TEST(SerializeBasic, ExpressionEqSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNeSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$ne: {a: 1}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -276,7 +276,7 @@ TEST(SerializeBasic, ExpressionNeSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionLtSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$lt: 3}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -291,7 +291,7 @@ TEST(SerializeBasic, ExpressionLtSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionGtSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$gt: 3}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -306,7 +306,7 @@ TEST(SerializeBasic, ExpressionGtSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionGteSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$gte: 3}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -321,7 +321,7 @@ TEST(SerializeBasic, ExpressionGteSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionLteSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$lte: 3}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -336,7 +336,7 @@ TEST(SerializeBasic, ExpressionLteSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionRegexWithObjSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$regex: 'a.b'}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -351,7 +351,7 @@ TEST(SerializeBasic, ExpressionRegexWithObjSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionRegexWithValueSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: /a.b/i}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -366,7 +366,7 @@ TEST(SerializeBasic, ExpressionRegexWithValueSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionRegexWithValueAndOptionsSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: /a.b/}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -381,7 +381,7 @@ TEST(SerializeBasic, ExpressionRegexWithValueAndOptionsSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionRegexWithEqObjSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$eq: {$regex: 'a.b'}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -399,7 +399,7 @@ TEST(SerializeBasic, ExpressionRegexWithEqObjSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionModSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$mod: [2, 1]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -414,7 +414,7 @@ TEST(SerializeBasic, ExpressionModSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionExistsTrueSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$exists: true}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -429,7 +429,7 @@ TEST(SerializeBasic, ExpressionExistsTrueSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionExistsFalseSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$exists: false}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -444,7 +444,7 @@ TEST(SerializeBasic, ExpressionExistsFalseSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionInSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$in: [1, 2, 3]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -462,7 +462,7 @@ TEST(SerializeBasic, ExpressionInSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionInWithEmptyArraySerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$in: []}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -474,7 +474,7 @@ TEST(SerializeBasic, ExpressionInWithEmptyArraySerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionInWithRegexSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$in: [/\\d+/, /\\w+/]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -492,7 +492,7 @@ TEST(SerializeBasic, ExpressionInWithRegexSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNinSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$nin: [1, 2, 3]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -510,7 +510,7 @@ TEST(SerializeBasic, ExpressionNinSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionBitsAllSetSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$bitsAllSet: [1, 3]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -525,7 +525,7 @@ TEST(SerializeBasic, ExpressionBitsAllSetSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionBitsAllClearSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$bitsAllClear: [1, 3]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -540,7 +540,7 @@ TEST(SerializeBasic, ExpressionBitsAllClearSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionBitsAnySetSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$bitsAnySet: [1, 3]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -555,7 +555,7 @@ TEST(SerializeBasic, ExpressionBitsAnySetSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionBitsAnyClearSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$bitsAnyClear: [1, 3]}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -573,7 +573,7 @@ TEST(SerializeBasic, ExpressionBitsAnyClearSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$not: {$eq: 3}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -588,7 +588,7 @@ TEST(SerializeBasic, ExpressionNotSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotWithMultipleChildrenSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$not: {$lt: 1, $gt: 3}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -604,7 +604,7 @@ TEST(SerializeBasic, ExpressionNotWithMultipleChildrenSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotWithBitTestSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson("{x: {$not: {$bitsAnySet: [1, 3]}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
@@ -620,7 +620,7 @@ TEST(SerializeBasic, ExpressionNotWithBitTestSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotWithRegexObjSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$not: {$regex: 'a.b'}}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -635,7 +635,7 @@ TEST(SerializeBasic, ExpressionNotWithRegexObjSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotWithRegexValueSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$not: /a.b/}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -650,7 +650,7 @@ TEST(SerializeBasic, ExpressionNotWithRegexValueSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotWithRegexValueAndOptionsSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$not: /a.b/i}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -665,7 +665,7 @@ TEST(SerializeBasic, ExpressionNotWithRegexValueAndOptionsSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNotWithGeoSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson(
"{x: {$not: {$geoIntersects: {$geometry: {type: 'Polygon', "
"coordinates: [[[0,0], [5,0], "
@@ -696,7 +696,7 @@ TEST(SerializeBasic, ExpressionNotWithGeoSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNorSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson("{$nor: [{x: 3}, {x: {$lt: 1}}]}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
@@ -715,7 +715,7 @@ TEST(SerializeBasic, ExpressionNorSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionTypeSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$type: 2}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -730,7 +730,7 @@ TEST(SerializeBasic, ExpressionTypeSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionTypeWithNumberSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{x: {$type: 'number'}}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -745,7 +745,7 @@ TEST(SerializeBasic, ExpressionTypeWithNumberSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionEmptySerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -757,7 +757,7 @@ TEST(SerializeBasic, ExpressionEmptySerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionWhereSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$where: 'this.a == this.b'}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -767,7 +767,7 @@ TEST(SerializeBasic, ExpressionWhereSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionWhereWithScopeSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(BSON("$where" << BSONCodeWScope("this.a == this.b", BSON("x" << 3))),
ExtensionsCallbackNoop(),
collator);
@@ -779,7 +779,7 @@ TEST(SerializeBasic, ExpressionWhereWithScopeSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionCommentSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$comment: 'Hello'}"), ExtensionsCallbackNoop(), collator);
Matcher reserialized(
serialize(original.getMatchExpression()), ExtensionsCallbackNoop(), collator);
@@ -794,7 +794,7 @@ TEST(SerializeBasic, ExpressionCommentSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionGeoWithinSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson(
"{x: {$geoWithin: {$geometry: "
@@ -817,7 +817,7 @@ TEST(SerializeBasic, ExpressionGeoWithinSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionGeoIntersectsSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson(
"{x: {$geoIntersects: {$geometry: {type: 'Polygon', coordinates: [[[0,0], [5,0], [5, "
@@ -847,7 +847,7 @@ TEST(SerializeBasic, ExpressionGeoIntersectsSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNearSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson(
"{x: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}, $maxDistance: 10, "
@@ -864,7 +864,7 @@ TEST(SerializeBasic, ExpressionNearSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionNearSphereSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(
fromjson(
"{x: {$nearSphere: {$geometry: {type: 'Point', coordinates: [0, 0]}, $maxDistance: 10, "
@@ -881,7 +881,7 @@ TEST(SerializeBasic, ExpressionNearSphereSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionTextSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$text: {$search: 'a', $language: 'en', $caseSensitive: true}}"),
ExtensionsCallbackNoop(),
collator);
@@ -895,7 +895,7 @@ TEST(SerializeBasic, ExpressionTextSerializesCorrectly) {
}
TEST(SerializeBasic, ExpressionTextWithDefaultLanguageSerializesCorrectly) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
Matcher original(fromjson("{$text: {$search: 'a', $caseSensitive: false}}"),
ExtensionsCallbackNoop(),
collator);
diff --git a/src/mongo/db/matcher/expression_test.cpp b/src/mongo/db/matcher/expression_test.cpp
index 57e8f1c8f7f..1ca7eefa856 100644
--- a/src/mongo/db/matcher/expression_test.cpp
+++ b/src/mongo/db/matcher/expression_test.cpp
@@ -47,7 +47,7 @@ TEST(MatchExpressionTest, Parse1) {
TEST(LeafMatchExpressionTest, Equal1) {
BSONObj temp = BSON("x" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression e(collator);
e.init("x", temp["x"]);
@@ -67,7 +67,7 @@ TEST(LeafMatchExpressionTest, Comp1) {
BSONObj temp = BSON("x" << 5);
{
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTEMatchExpression e(collator);
e.init("x", temp["x"]);
ASSERT_TRUE(e.matchesBSON(fromjson("{ x : 5 }")));
@@ -77,7 +77,7 @@ TEST(LeafMatchExpressionTest, Comp1) {
}
{
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
LTMatchExpression e(collator);
e.init("x", temp["x"]);
ASSERT_FALSE(e.matchesBSON(fromjson("{ x : 5 }")));
@@ -87,7 +87,7 @@ TEST(LeafMatchExpressionTest, Comp1) {
}
{
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTEMatchExpression e(collator);
e.init("x", temp["x"]);
ASSERT_TRUE(e.matchesBSON(fromjson("{ x : 5 }")));
@@ -97,7 +97,7 @@ TEST(LeafMatchExpressionTest, Comp1) {
}
{
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
GTMatchExpression e(collator);
e.init("x", temp["x"]);
ASSERT_FALSE(e.matchesBSON(fromjson("{ x : 5 }")));
diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp
index e8aa987ab32..9799f25ccc4 100644
--- a/src/mongo/db/matcher/expression_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_tree_test.cpp
@@ -42,7 +42,7 @@ using std::unique_ptr;
TEST(NotMatchExpression, MatchesScalar) {
BSONObj baseOperand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator));
ASSERT(lt->init("a", baseOperand["$lt"]).isOK());
NotMatchExpression notOp;
@@ -53,7 +53,7 @@ TEST(NotMatchExpression, MatchesScalar) {
TEST(NotMatchExpression, MatchesArray) {
BSONObj baseOperand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator));
ASSERT(lt->init("a", baseOperand["$lt"]).isOK());
NotMatchExpression notOp;
@@ -66,7 +66,7 @@ TEST(NotMatchExpression, MatchesArray) {
TEST(NotMatchExpression, ElemMatchKey) {
BSONObj baseOperand = BSON("$lt" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator));
ASSERT(lt->init("a", baseOperand["$lt"]).isOK());
NotMatchExpression notOp;
@@ -130,7 +130,7 @@ TEST(AndOp, MatchesElementThreeClauses) {
BSONObj notMatch3 = BSON("a"
<< "r");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new LTMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["$lt"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new GTMatchExpression(collator));
@@ -151,7 +151,7 @@ TEST(AndOp, MatchesElementThreeClauses) {
TEST(AndOp, MatchesSingleClause) {
BSONObj baseOperand = BSON("$ne" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("a", baseOperand["$ne"]).isOK());
unique_ptr<NotMatchExpression> ne(new NotMatchExpression());
@@ -171,7 +171,7 @@ TEST(AndOp, MatchesThreeClauses) {
BSONObj baseOperand2 = BSON("$lt" << 10);
BSONObj baseOperand3 = BSON("$lt" << 100);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK());
@@ -197,7 +197,7 @@ TEST(AndOp, ElemMatchKey) {
BSONObj baseOperand1 = BSON("a" << 1);
BSONObj baseOperand2 = BSON("b" << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["a"]).isOK());
@@ -318,7 +318,7 @@ TEST( OrOp, MatchesElementThreeClauses ) {
*/
TEST(OrOp, MatchesSingleClause) {
BSONObj baseOperand = BSON("$ne" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("a", baseOperand["$ne"]).isOK());
unique_ptr<NotMatchExpression> ne(new NotMatchExpression());
@@ -337,7 +337,7 @@ TEST(OrOp, MatchesThreeClauses) {
BSONObj baseOperand1 = BSON("$gt" << 10);
BSONObj baseOperand2 = BSON("$lt" << 0);
BSONObj baseOperand3 = BSON("b" << 100);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression(collator));
@@ -362,7 +362,7 @@ TEST(OrOp, MatchesThreeClauses) {
TEST(OrOp, ElemMatchKey) {
BSONObj baseOperand1 = BSON("a" << 1);
BSONObj baseOperand2 = BSON("b" << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["a"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression(collator));
@@ -482,7 +482,7 @@ TEST( NorOp, MatchesElementThreeClauses ) {
TEST(NorOp, MatchesSingleClause) {
BSONObj baseOperand = BSON("$ne" << 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
ASSERT(eq->init("a", baseOperand["$ne"]).isOK());
unique_ptr<NotMatchExpression> ne(new NotMatchExpression());
@@ -502,7 +502,7 @@ TEST(NorOp, MatchesThreeClauses) {
BSONObj baseOperand2 = BSON("$lt" << 0);
BSONObj baseOperand3 = BSON("b" << 100);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression(collator));
@@ -527,7 +527,7 @@ TEST(NorOp, MatchesThreeClauses) {
TEST(NorOp, ElemMatchKey) {
BSONObj baseOperand1 = BSON("a" << 1);
BSONObj baseOperand2 = BSON("b" << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression(collator));
ASSERT(sub1->init("a", baseOperand1["a"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression(collator));
@@ -552,7 +552,7 @@ TEST(NorOp, ElemMatchKey) {
TEST(NorOp, Equivalent) {
BSONObj baseOperand1 = BSON("a" << 1);
BSONObj baseOperand2 = BSON("b" << 2);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
EqualityMatchExpression sub1(collator);
ASSERT(sub1.init("a", baseOperand1["a"]).isOK());
EqualityMatchExpression sub2(collator);
@@ -568,20 +568,4 @@ TEST(NorOp, Equivalent) {
ASSERT(e1.equivalent(&e1));
ASSERT(!e1.equivalent(&e2));
}
-
-/**
-TEST( NorOp, MatchesIndexKey ) {
- BSONObj baseOperand = BSON( "a" << 5 );
- unique_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() );
- ASSERT( eq->init( "a", baseOperand[ "a" ] ).isOK() );
- OwnedPointerVector<MatchMatchExpression> subMatchExpressions;
- subMatchExpressions.mutableVector().push_back( eq.release() );
- NorOp norOp;
- ASSERT( norOp.init( &subMatchExpressions ).isOK() );
- IndexSpec indexSpec( BSON( "a" << 1 ) );
- BSONObj indexKey = BSON( "" << "7" );
- ASSERT( MatchMatchExpression::PartialMatchResult_Unknown ==
- norOp.matchesIndexKey( indexKey, indexSpec ) );
-}
-*/
}
diff --git a/src/mongo/db/matcher/matcher.cpp b/src/mongo/db/matcher/matcher.cpp
index 0668848c4ad..6fa7eec44b5 100644
--- a/src/mongo/db/matcher/matcher.cpp
+++ b/src/mongo/db/matcher/matcher.cpp
@@ -43,7 +43,7 @@ namespace mongo {
Matcher::Matcher(const BSONObj& pattern,
const ExtensionsCallback& extensionsCallback,
- CollatorInterface* collator)
+ const CollatorInterface* collator)
: _pattern(pattern) {
StatusWithMatchExpression statusWithMatcher =
MatchExpressionParser::parse(pattern, extensionsCallback, collator);
diff --git a/src/mongo/db/matcher/matcher.h b/src/mongo/db/matcher/matcher.h
index 3d64908036e..e37a6a0a3b5 100644
--- a/src/mongo/db/matcher/matcher.h
+++ b/src/mongo/db/matcher/matcher.h
@@ -55,7 +55,7 @@ public:
*/
explicit Matcher(const BSONObj& pattern,
const ExtensionsCallback& extensionsCallback,
- CollatorInterface* collator);
+ const CollatorInterface* collator);
bool matches(const BSONObj& doc, MatchDetails* details = NULL) const;
diff --git a/src/mongo/db/ops/modifier_interface.h b/src/mongo/db/ops/modifier_interface.h
index 6afe4547034..4eeaa773fe8 100644
--- a/src/mongo/db/ops/modifier_interface.h
+++ b/src/mongo/db/ops/modifier_interface.h
@@ -154,19 +154,19 @@ public:
*/
struct ModifierInterface::Options {
Options() = default;
- Options(bool repl, bool ofs, CollatorInterface* collator)
+ Options(bool repl, bool ofs, const CollatorInterface* collator)
: fromReplication(repl), enforceOkForStorage(ofs), collator(collator) {}
- static Options normal(CollatorInterface* collator = nullptr) {
+ static Options normal(const CollatorInterface* collator = nullptr) {
return Options(false, true, collator);
}
- static Options fromRepl(CollatorInterface* collator = nullptr) {
+ static Options fromRepl(const CollatorInterface* collator = nullptr) {
return Options(true, false, collator);
}
bool fromReplication = false;
bool enforceOkForStorage = true;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
};
struct ModifierInterface::ExecInfo {
diff --git a/src/mongo/db/ops/modifier_pull.h b/src/mongo/db/ops/modifier_pull.h
index f6618f17155..a8238ea60eb 100644
--- a/src/mongo/db/ops/modifier_pull.h
+++ b/src/mongo/db/ops/modifier_pull.h
@@ -80,7 +80,7 @@ private:
// The collator which must be used for matching strings. Null if we should use a simple binary
// comparison.
- CollatorInterface* _collator = nullptr;
+ const CollatorInterface* _collator = nullptr;
struct PreparedState;
std::unique_ptr<PreparedState> _preparedState;
diff --git a/src/mongo/db/ops/modifier_pull_test.cpp b/src/mongo/db/ops/modifier_pull_test.cpp
index 64c99ab83c5..d4d2fe12bda 100644
--- a/src/mongo/db/ops/modifier_pull_test.cpp
+++ b/src/mongo/db/ops/modifier_pull_test.cpp
@@ -64,7 +64,7 @@ public:
ModifierInterface::Options::normal()));
}
- Mod(BSONObj modObj, CollatorInterface* collator) : _modObj(modObj), _mod() {
+ Mod(BSONObj modObj, const CollatorInterface* collator) : _modObj(modObj), _mod() {
ASSERT_OK(_mod.init(_modObj["$pull"].embeddedObject().firstElement(),
ModifierInterface::Options::normal(collator)));
}
diff --git a/src/mongo/db/ops/path_support_test.cpp b/src/mongo/db/ops/path_support_test.cpp
index a5d5e060de9..01345564ccd 100644
--- a/src/mongo/db/ops/path_support_test.cpp
+++ b/src/mongo/db/ops/path_support_test.cpp
@@ -521,7 +521,7 @@ TEST_F(ArrayDoc, NonNumericPathInArray) {
//
static MatchExpression* makeExpr(const BSONObj& exprBSON) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
return MatchExpressionParser::parse(exprBSON, ExtensionsCallbackDisallowExtensions(), collator)
.getValue()
.release();
diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp
index dcfbefcaf77..05c95409f7e 100644
--- a/src/mongo/db/query/canonical_query_test.cpp
+++ b/src/mongo/db/query/canonical_query_test.cpp
@@ -51,7 +51,7 @@ static const NamespaceString nss("testdb.testcoll");
* and return the MatchExpression*.
*/
MatchExpression* parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackNoop(), collator);
if (!status.isOK()) {
diff --git a/src/mongo/db/query/collation/collation_index_key.cpp b/src/mongo/db/query/collation/collation_index_key.cpp
index 8d30061d8a9..eb25acc3f79 100644
--- a/src/mongo/db/query/collation/collation_index_key.cpp
+++ b/src/mongo/db/query/collation/collation_index_key.cpp
@@ -37,14 +37,15 @@
namespace mongo {
// TODO SERVER-23172: Update this to consider strings inside nested objects or arrays.
-bool CollationIndexKey::shouldUseCollationIndexKey(BSONElement elt, CollatorInterface* collator) {
+bool CollationIndexKey::shouldUseCollationIndexKey(BSONElement elt,
+ const CollatorInterface* collator) {
return collator && elt.type() == BSONType::String;
}
// TODO SERVER-23172: Update this to convert strings inside nested objects or arrays to their
// corresponding comparison keys.
void CollationIndexKey::collationAwareIndexKeyAppend(BSONElement elt,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
BSONObjBuilder* out) {
if (shouldUseCollationIndexKey(elt, collator)) {
auto comparisonKey = collator->getComparisonKey(elt.valueStringData());
diff --git a/src/mongo/db/query/collation/collation_index_key.h b/src/mongo/db/query/collation/collation_index_key.h
index 480ab464934..7d86935b11a 100644
--- a/src/mongo/db/query/collation/collation_index_key.h
+++ b/src/mongo/db/query/collation/collation_index_key.h
@@ -43,14 +43,14 @@ public:
/**
* Returns true if the index key for 'elt' should be a comparison key generated by 'collator'.
*/
- static bool shouldUseCollationIndexKey(BSONElement elt, CollatorInterface* collator);
+ static bool shouldUseCollationIndexKey(BSONElement elt, const CollatorInterface* collator);
/**
* Appends 'elt' to 'out' with an empty field name, converting strings to comparison keys
* generated by 'collator' if necessary.
*/
static void collationAwareIndexKeyAppend(BSONElement elt,
- CollatorInterface* collator,
+ const CollatorInterface* collator,
BSONObjBuilder* out);
};
diff --git a/src/mongo/db/query/collation/collator_interface.h b/src/mongo/db/query/collation/collator_interface.h
index 962ccadb718..c86e1390fa5 100644
--- a/src/mongo/db/query/collation/collator_interface.h
+++ b/src/mongo/db/query/collation/collator_interface.h
@@ -95,13 +95,13 @@ public:
* 0 if 'left' is greater than 'right' w.r.t. the collation, and 0 if 'left' and 'right' are
* equal w.r.t. the collation.
*/
- virtual int compare(StringData left, StringData right) = 0;
+ virtual int compare(StringData left, StringData right) const = 0;
/**
* Returns the comparison key for 'stringData', according to this collation. See ComparisonKey's
* comments for details.
*/
- virtual ComparisonKey getComparisonKey(StringData stringData) = 0;
+ virtual ComparisonKey getComparisonKey(StringData stringData) const = 0;
/**
* Returns whether this collation has the same matching and sorting semantics as 'other'.
diff --git a/src/mongo/db/query/collation/collator_interface_icu.cpp b/src/mongo/db/query/collation/collator_interface_icu.cpp
index 7a6dbc2df8f..01895284cbe 100644
--- a/src/mongo/db/query/collation/collator_interface_icu.cpp
+++ b/src/mongo/db/query/collation/collator_interface_icu.cpp
@@ -40,7 +40,7 @@ CollatorInterfaceICU::CollatorInterfaceICU(CollationSpec spec,
std::unique_ptr<icu::Collator> collator)
: CollatorInterface(std::move(spec)), _collator(std::move(collator)) {}
-int CollatorInterfaceICU::compare(StringData left, StringData right) {
+int CollatorInterfaceICU::compare(StringData left, StringData right) const {
UErrorCode status = U_ZERO_ERROR;
auto compareResult = _collator->compareUTF8(icu::StringPiece(left.rawData(), left.size()),
icu::StringPiece(right.rawData(), right.size()),
@@ -63,7 +63,8 @@ int CollatorInterfaceICU::compare(StringData left, StringData right) {
MONGO_UNREACHABLE;
}
-CollatorInterface::ComparisonKey CollatorInterfaceICU::getComparisonKey(StringData stringData) {
+CollatorInterface::ComparisonKey CollatorInterfaceICU::getComparisonKey(
+ StringData stringData) const {
// A StringPiece is ICU's StringData. They are logically the same abstraction.
const icu::StringPiece stringPiece(stringData.rawData(), stringData.size());
diff --git a/src/mongo/db/query/collation/collator_interface_icu.h b/src/mongo/db/query/collation/collator_interface_icu.h
index d4e3c15e804..a706ee1341d 100644
--- a/src/mongo/db/query/collation/collator_interface_icu.h
+++ b/src/mongo/db/query/collation/collator_interface_icu.h
@@ -43,9 +43,9 @@ class CollatorInterfaceICU final : public CollatorInterface {
public:
CollatorInterfaceICU(CollationSpec spec, std::unique_ptr<icu::Collator> collator);
- int compare(StringData left, StringData right) final;
+ int compare(StringData left, StringData right) const final;
- ComparisonKey getComparisonKey(StringData stringData) final;
+ ComparisonKey getComparisonKey(StringData stringData) const final;
private:
// The ICU implementation of the collator to which we delegate interesting work. Const methods
diff --git a/src/mongo/db/query/collation/collator_interface_mock.cpp b/src/mongo/db/query/collation/collator_interface_mock.cpp
index 42a8234bb67..e6bf1799f38 100644
--- a/src/mongo/db/query/collation/collator_interface_mock.cpp
+++ b/src/mongo/db/query/collation/collator_interface_mock.cpp
@@ -54,7 +54,7 @@ std::string mockTypeToString(CollatorInterfaceMock::MockType type) {
CollatorInterfaceMock::CollatorInterfaceMock(MockType mockType)
: CollatorInterface(CollationSpec(mockTypeToString(mockType))), _mockType(mockType) {}
-int CollatorInterfaceMock::compare(StringData left, StringData right) {
+int CollatorInterfaceMock::compare(StringData left, StringData right) const {
switch (_mockType) {
case MockType::kReverseString: {
std::string leftString = left.toString();
@@ -72,7 +72,8 @@ int CollatorInterfaceMock::compare(StringData left, StringData right) {
MONGO_UNREACHABLE;
}
-CollatorInterface::ComparisonKey CollatorInterfaceMock::getComparisonKey(StringData stringData) {
+CollatorInterface::ComparisonKey CollatorInterfaceMock::getComparisonKey(
+ StringData stringData) const {
switch (_mockType) {
case MockType::kReverseString: {
std::string keyDataString = stringData.toString();
diff --git a/src/mongo/db/query/collation/collator_interface_mock.h b/src/mongo/db/query/collation/collator_interface_mock.h
index 9175358c8aa..a5191502d0c 100644
--- a/src/mongo/db/query/collation/collator_interface_mock.h
+++ b/src/mongo/db/query/collation/collator_interface_mock.h
@@ -57,9 +57,9 @@ public:
*/
CollatorInterfaceMock(MockType mockType);
- int compare(StringData left, StringData right) final;
+ int compare(StringData left, StringData right) const final;
- ComparisonKey getComparisonKey(StringData stringData) final;
+ ComparisonKey getComparisonKey(StringData stringData) const final;
private:
const MockType _mockType;
diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp
index 859caf4b737..40ea382c8f8 100644
--- a/src/mongo/db/query/index_bounds_builder.cpp
+++ b/src/mongo/db/query/index_bounds_builder.cpp
@@ -769,7 +769,8 @@ Interval IndexBoundsBuilder::makePointInterval(double d) {
}
// static
-BSONObj IndexBoundsBuilder::objFromElement(const BSONElement& elt, CollatorInterface* collator) {
+BSONObj IndexBoundsBuilder::objFromElement(const BSONElement& elt,
+ const CollatorInterface* collator) {
BSONObjBuilder bob;
CollationIndexKey::collationAwareIndexKeyAppend(elt, collator, &bob);
return bob.obj();
diff --git a/src/mongo/db/query/index_bounds_builder.h b/src/mongo/db/query/index_bounds_builder.h
index 2a1adbd1241..b37901f6d2d 100644
--- a/src/mongo/db/query/index_bounds_builder.h
+++ b/src/mongo/db/query/index_bounds_builder.h
@@ -131,7 +131,7 @@ public:
* string, and 'collator' is non-null, the result contains the collator-generated comparison key
* rather than the original string.
*/
- static BSONObj objFromElement(const BSONElement& elt, CollatorInterface* collator);
+ static BSONObj objFromElement(const BSONElement& elt, const CollatorInterface* collator);
/**
* Swap start/end in the provided interval.
diff --git a/src/mongo/db/query/index_bounds_builder_test.cpp b/src/mongo/db/query/index_bounds_builder_test.cpp
index 3380562599b..4d93b8b63c9 100644
--- a/src/mongo/db/query/index_bounds_builder_test.cpp
+++ b/src/mongo/db/query/index_bounds_builder_test.cpp
@@ -59,7 +59,7 @@ double NaN = numeric_limits<double>::quiet_NaN();
* Utility function to create MatchExpression
*/
MatchExpression* parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(status.isOK());
diff --git a/src/mongo/db/query/index_entry.h b/src/mongo/db/query/index_entry.h
index 8af72ce93db..7b336515954 100644
--- a/src/mongo/db/query/index_entry.h
+++ b/src/mongo/db/query/index_entry.h
@@ -125,7 +125,7 @@ struct IndexEntry {
// Null if this index orders strings according to the simple binary compare. If non-null,
// represents the collator used to generate index keys for indexed strings.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
};
} // namespace mongo
diff --git a/src/mongo/db/query/parsed_projection.cpp b/src/mongo/db/query/parsed_projection.cpp
index 199b9abe557..f3ebf7736b0 100644
--- a/src/mongo/db/query/parsed_projection.cpp
+++ b/src/mongo/db/query/parsed_projection.cpp
@@ -127,7 +127,7 @@ Status ParsedProjection::make(const BSONObj& spec,
// only parsing here in order to ensure that the elemMatch projection is valid.
//
// TODO: Is there a faster way of validating the elemMatchObj?
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher =
MatchExpressionParser::parse(elemMatchObj, extensionsCallback, collator);
if (!statusWithMatcher.isOK()) {
diff --git a/src/mongo/db/query/parsed_projection_test.cpp b/src/mongo/db/query/parsed_projection_test.cpp
index 5b246d8f4d4..90f1b9bfb5c 100644
--- a/src/mongo/db/query/parsed_projection_test.cpp
+++ b/src/mongo/db/query/parsed_projection_test.cpp
@@ -47,7 +47,7 @@ using namespace mongo;
//
unique_ptr<ParsedProjection> createParsedProjection(const BSONObj& query, const BSONObj& projObj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(statusWithMatcher.isOK());
@@ -76,7 +76,7 @@ unique_ptr<ParsedProjection> createParsedProjection(const char* queryStr, const
void assertInvalidProjection(const char* queryStr, const char* projStr) {
BSONObj query = fromjson(queryStr);
BSONObj projObj = fromjson(projStr);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(statusWithMatcher.isOK());
diff --git a/src/mongo/db/query/plan_cache_indexability_test.cpp b/src/mongo/db/query/plan_cache_indexability_test.cpp
index 9d64ea157c2..48abdc58c89 100644
--- a/src/mongo/db/query/plan_cache_indexability_test.cpp
+++ b/src/mongo/db/query/plan_cache_indexability_test.cpp
@@ -36,7 +36,7 @@ namespace mongo {
namespace {
std::unique_ptr<MatchExpression> parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions(), collator);
if (!status.isOK()) {
diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp
index 51ae170d3ae..61e803af8af 100644
--- a/src/mongo/db/query/plan_cache_test.cpp
+++ b/src/mongo/db/query/plan_cache_test.cpp
@@ -151,7 +151,7 @@ unique_ptr<CanonicalQuery> canonicalize(const char* queryStr,
* Utility function to create MatchExpression
*/
unique_ptr<MatchExpression> parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions(), collator);
if (!status.isOK()) {
diff --git a/src/mongo/db/query/planner_ixselect_test.cpp b/src/mongo/db/query/planner_ixselect_test.cpp
index 47c64a049ae..14c46e47970 100644
--- a/src/mongo/db/query/planner_ixselect_test.cpp
+++ b/src/mongo/db/query/planner_ixselect_test.cpp
@@ -53,7 +53,7 @@ using std::vector;
* Utility function to create MatchExpression
*/
unique_ptr<MatchExpression> parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_TRUE(status.isOK());
diff --git a/src/mongo/db/query/query_planner_params.h b/src/mongo/db/query/query_planner_params.h
index cfba6b82b50..b9bbfead272 100644
--- a/src/mongo/db/query/query_planner_params.h
+++ b/src/mongo/db/query/query_planner_params.h
@@ -121,7 +121,7 @@ struct QueryPlannerParams {
// The collation which this query must respect. Distinct from the CollatorInterfaces attached to
// the IndexEntry instances, which give the physical properties of the indices rather than the
// logical collation which the query must use.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
};
} // namespace mongo
diff --git a/src/mongo/db/query/query_planner_test_fixture.cpp b/src/mongo/db/query/query_planner_test_fixture.cpp
index 288c010c8dd..0e336528b45 100644
--- a/src/mongo/db/query/query_planner_test_fixture.cpp
+++ b/src/mongo/db/query/query_planner_test_fixture.cpp
@@ -122,7 +122,7 @@ void QueryPlannerTest::addIndex(BSONObj keyPattern, const MultikeyPaths& multike
params.indices.push_back(entry);
}
-void QueryPlannerTest::addIndex(BSONObj keyPattern, CollatorInterface* collator) {
+void QueryPlannerTest::addIndex(BSONObj keyPattern, const CollatorInterface* collator) {
const bool sparse = false;
const bool unique = false;
const bool multikey = false;
@@ -374,7 +374,7 @@ void QueryPlannerTest::assertHasOneSolutionOf(const std::vector<std::string>& so
}
std::unique_ptr<MatchExpression> QueryPlannerTest::parseMatchExpression(const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression status =
MatchExpressionParser::parse(obj, ExtensionsCallbackDisallowExtensions(), collator);
if (!status.isOK()) {
diff --git a/src/mongo/db/query/query_planner_test_fixture.h b/src/mongo/db/query/query_planner_test_fixture.h
index 5ef2490e171..0a2bfcc8b1a 100644
--- a/src/mongo/db/query/query_planner_test_fixture.h
+++ b/src/mongo/db/query/query_planner_test_fixture.h
@@ -63,7 +63,7 @@ protected:
void addIndex(BSONObj keyPattern, const MultikeyPaths& multikeyPaths);
- void addIndex(BSONObj keyPattern, CollatorInterface* collator);
+ void addIndex(BSONObj keyPattern, const CollatorInterface* collator);
//
// Execute planner.
diff --git a/src/mongo/db/query/query_planner_test_lib.cpp b/src/mongo/db/query/query_planner_test_lib.cpp
index ba0bc5d569a..f6ef22bb610 100644
--- a/src/mongo/db/query/query_planner_test_lib.cpp
+++ b/src/mongo/db/query/query_planner_test_lib.cpp
@@ -52,7 +52,7 @@ bool filterMatches(const BSONObj& testFilter, const QuerySolutionNode* trueFilte
if (NULL == trueFilterNode->filter) {
return false;
}
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher =
MatchExpressionParser::parse(testFilter, ExtensionsCallbackDisallowExtensions(), collator);
if (!statusWithMatcher.isOK()) {
diff --git a/src/mongo/db/query/query_solution_test.cpp b/src/mongo/db/query/query_solution_test.cpp
index 913a76609f0..ac1b6abbac1 100644
--- a/src/mongo/db/query/query_solution_test.cpp
+++ b/src/mongo/db/query/query_solution_test.cpp
@@ -251,7 +251,7 @@ TEST(QuerySolutionTest, IntervalListSomePoints) {
std::unique_ptr<ParsedProjection> createParsedProjection(const BSONObj& query,
const BSONObj& projObj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression queryMatchExpr =
MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(queryMatchExpr.isOK());
diff --git a/src/mongo/dbtests/matchertests.cpp b/src/mongo/dbtests/matchertests.cpp
index ce24738b325..73b5c728511 100644
--- a/src/mongo/dbtests/matchertests.cpp
+++ b/src/mongo/dbtests/matchertests.cpp
@@ -62,7 +62,7 @@ class Basic {
public:
void run() {
BSONObj query = fromjson("{\"a\":\"b\"}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(m.matches(fromjson("{\"a\":\"b\"}")));
}
@@ -73,7 +73,7 @@ class DoubleEqual {
public:
void run() {
BSONObj query = fromjson("{\"a\":5}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(query, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(m.matches(fromjson("{\"a\":5}")));
}
@@ -85,7 +85,7 @@ public:
void run() {
BSONObjBuilder query;
query.append("a", 5);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(query.done(), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(m.matches(fromjson("{\"a\":5}")));
}
@@ -96,7 +96,7 @@ class MixedNumericGt {
public:
void run() {
BSONObj query = fromjson("{\"a\":{\"$gt\":4}}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(query, ExtensionsCallbackDisallowExtensions(), collator);
BSONObjBuilder b;
b.append("a", 5);
@@ -112,7 +112,7 @@ public:
ASSERT_EQUALS(4, query["a"].embeddedObject()["$in"].embeddedObject()["0"].number());
ASSERT_EQUALS(NumberInt, query["a"].embeddedObject()["$in"].embeddedObject()["0"].type());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(query, ExtensionsCallbackDisallowExtensions(), collator);
{
@@ -140,7 +140,7 @@ template <typename M>
class MixedNumericEmbedded {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(BSON("a" << BSON("x" << 1)), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(m.matches(BSON("a" << BSON("x" << 1))));
ASSERT(m.matches(BSON("a" << BSON("x" << 1.0))));
@@ -151,7 +151,7 @@ template <typename M>
class Size {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(fromjson("{a:{$size:4}}"), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(m.matches(fromjson("{a:[1,2,3,4]}")));
ASSERT(!m.matches(fromjson("{a:[1,2,3]}")));
@@ -164,7 +164,7 @@ template <typename M>
class WithinBox {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(fromjson("{loc:{$within:{$box:[{x: 4, y:4},[6,6]]}}}"),
ExtensionsCallbackDisallowExtensions(),
collator);
@@ -180,7 +180,7 @@ template <typename M>
class WithinPolygon {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(fromjson("{loc:{$within:{$polygon:[{x:0,y:0},[0,5],[5,5],[5,0]]}}}"),
ExtensionsCallbackDisallowExtensions(),
collator);
@@ -196,7 +196,7 @@ template <typename M>
class WithinCenter {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(fromjson("{loc:{$within:{$center:[{x:30,y:30},10]}}}"),
ExtensionsCallbackDisallowExtensions(),
collator);
@@ -215,7 +215,7 @@ template <typename M>
class ElemMatchKey {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M matcher(BSON("a.b" << 1), ExtensionsCallbackDisallowExtensions(), collator);
MatchDetails details;
details.requestElemMatchKey();
@@ -236,7 +236,7 @@ public:
const NamespaceString nss("unittests.matchertests");
AutoGetCollectionForRead ctx(&txn, nss);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(BSON("$where"
<< "function(){ return this.a == 1; }"),
ExtensionsCallbackReal(&txn, &nss),
@@ -250,7 +250,7 @@ template <typename M>
class TimingBase {
public:
long dotime(const BSONObj& patt, const BSONObj& obj) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M m(patt, ExtensionsCallbackDisallowExtensions(), collator);
Timer t;
for (int i = 0; i < 900000; i++) {
@@ -281,7 +281,7 @@ template <typename M>
class NullCollator {
public:
void run() {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
M matcher(BSON("a"
<< "string"),
ExtensionsCallbackDisallowExtensions(),
diff --git a/src/mongo/dbtests/namespacetests.cpp b/src/mongo/dbtests/namespacetests.cpp
index e7f7a1220db..b6d29ca2ddd 100644
--- a/src/mongo/dbtests/namespacetests.cpp
+++ b/src/mongo/dbtests/namespacetests.cpp
@@ -101,7 +101,7 @@ public:
// Call getKeys on the nullObj.
BSONObjSet nullFieldKeySet;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ExpressionKeysPrivate::getHashKeys(nullObj, "a", 0, 0, false, collator, &nullFieldKeySet);
BSONElement nullFieldFromKey = nullFieldKeySet.begin()->firstElement();
@@ -128,7 +128,7 @@ public:
BSONObj nullObj = BSON("a" << BSONNULL);
BSONObjSet nullFieldKeySet;
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
ExpressionKeysPrivate::getHashKeys(
nullObj, "a", 0x5eed, 0, false, collator, &nullFieldKeySet);
BSONElement nullFieldFromKey = nullFieldKeySet.begin()->firstElement();
diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp
index cac7a702028..e8825f1bb44 100644
--- a/src/mongo/dbtests/query_stage_collscan.cpp
+++ b/src/mongo/dbtests/query_stage_collscan.cpp
@@ -90,7 +90,7 @@ public:
params.tailable = false;
// Make the filter.
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
filterObj, ExtensionsCallbackDisallowExtensions(), collator);
verify(statusWithMatcher.isOK());
diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp
index 82a645bdcde..e24e4047ce2 100644
--- a/src/mongo/dbtests/query_stage_count.cpp
+++ b/src/mongo/dbtests/query_stage_count.cpp
@@ -145,7 +145,7 @@ public:
unique_ptr<WorkingSet> ws(new WorkingSet);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
request.getQuery(), ExtensionsCallbackDisallowExtensions(), collator);
ASSERT(statusWithMatcher.isOK());
diff --git a/src/mongo/dbtests/query_stage_ensure_sorted.cpp b/src/mongo/dbtests/query_stage_ensure_sorted.cpp
index 3f8825b70cc..8ba3b552eeb 100644
--- a/src/mongo/dbtests/query_stage_ensure_sorted.cpp
+++ b/src/mongo/dbtests/query_stage_ensure_sorted.cpp
@@ -68,7 +68,7 @@ TEST(QueryStageEnsureSorted, EnsureSortedEmptyWorkingSet) {
void testWork(const char* patternStr,
const char* inputStr,
const char* expectedStr,
- CollatorInterface* collator = nullptr) {
+ const CollatorInterface* collator = nullptr) {
WorkingSet ws;
auto queuedDataStage = stdx::make_unique<QueuedDataStage>(nullptr, &ws);
BSONObj inputObj = fromjson(inputStr);
@@ -157,7 +157,7 @@ TEST(QueryStageEnsureSorted, EnsureSortedCompoundKey) {
}
TEST(QueryStageEnsureSorted, EnsureSortedStringsNullCollator) {
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
testWork("{a: 1}",
"{input: [{a: 'abc'}, {a: 'cba'}]}",
"{output: [{a: 'abc'}, {a: 'cba'}]}",
diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp
index 60158a3fd92..fef93098606 100644
--- a/src/mongo/dbtests/query_stage_fetch.cpp
+++ b/src/mongo/dbtests/query_stage_fetch.cpp
@@ -195,7 +195,7 @@ public:
// Make the filter.
BSONObj filterObj = BSON("foo" << 6);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
filterObj, ExtensionsCallbackDisallowExtensions(), collator);
verify(statusWithMatcher.isOK());
diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp
index ae5b128824a..8d16a859578 100644
--- a/src/mongo/dbtests/query_stage_multiplan.cpp
+++ b/src/mongo/dbtests/query_stage_multiplan.cpp
@@ -152,7 +152,7 @@ public:
// Make the filter.
BSONObj filterObj = BSON("foo" << 7);
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
filterObj, ExtensionsCallbackDisallowExtensions(), collator);
verify(statusWithMatcher.isOK());
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp
index b703c0bf74c..490069c7cae 100644
--- a/src/mongo/dbtests/query_stage_subplan.cpp
+++ b/src/mongo/dbtests/query_stage_subplan.cpp
@@ -449,7 +449,7 @@ public:
// Rewrite (AND (OR a b) e) => (OR (AND a e) (AND b e))
{
BSONObj queryObj = fromjson("{$or:[{a:1}, {b:1}], e:1}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression expr = MatchExpressionParser::parse(
queryObj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(expr.getStatus());
@@ -467,7 +467,7 @@ public:
// Rewrite (AND (OR a b) e f) => (OR (AND a e f) (AND b e f))
{
BSONObj queryObj = fromjson("{$or:[{a:1}, {b:1}], e:1, f:1}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression expr = MatchExpressionParser::parse(
queryObj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(expr.getStatus());
@@ -485,7 +485,7 @@ public:
// Rewrite (AND (OR (AND a b) (AND c d) e f) => (OR (AND a b e f) (AND c d e f))
{
BSONObj queryObj = fromjson("{$or:[{a:1,b:1}, {c:1,d:1}], e:1,f:1}");
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression expr = MatchExpressionParser::parse(
queryObj, ExtensionsCallbackDisallowExtensions(), collator);
ASSERT_OK(expr.getStatus());
diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp
index acd5010e01c..2347a49e429 100644
--- a/src/mongo/dbtests/query_stage_tests.cpp
+++ b/src/mongo/dbtests/query_stage_tests.cpp
@@ -80,7 +80,7 @@ public:
int countResults(const IndexScanParams& params, BSONObj filterObj = BSONObj()) {
AutoGetCollectionForRead ctx(&_txn, ns());
- CollatorInterface* collator = nullptr;
+ const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
filterObj, ExtensionsCallbackDisallowExtensions(), collator);
verify(statusWithMatcher.isOK());