summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/index_bounds_builder_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/index_bounds_builder_test.cpp')
-rw-r--r--src/mongo/db/query/index_bounds_builder_test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/query/index_bounds_builder_test.cpp b/src/mongo/db/query/index_bounds_builder_test.cpp
index 2d3ca2d0ac5..7ec1beb9f37 100644
--- a/src/mongo/db/query/index_bounds_builder_test.cpp
+++ b/src/mongo/db/query/index_bounds_builder_test.cpp
@@ -492,6 +492,32 @@ TEST_F(IndexBoundsBuilderTest, TranslateGtMinKey) {
ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);
}
+TEST_F(IndexBoundsBuilderTest, DontCrashOnNegationOfArrayInequality) {
+ BSONObj keyPattern = BSON("a" << 1);
+ auto testIndex = IndexEntry(keyPattern,
+ IndexNames::nameToType(IndexNames::findPluginName(keyPattern)),
+ true, // multikey
+ {},
+ {},
+ false, // sparse
+ false, // unique
+ IndexEntry::Identifier{"test_foo"},
+ nullptr, // filterExpr
+ BSONObj(),
+ nullptr,
+ nullptr);
+
+ BSONObj obj = fromjson("{a: {$not: {$lt: [\"here\", {}, false]}}}");
+ auto expr = MatchExpression::optimize(parseMatchExpression(obj));
+ BSONElement elt = obj.firstElement();
+ OrderedIntervalList oil;
+ IndexBoundsBuilder::BoundsTightness tightness;
+ // TODO: SERVER-45233 This should succeed rather than throwing code.
+ ASSERT_THROWS_CODE(IndexBoundsBuilder::translate(expr.get(), elt, testIndex, &oil, &tightness),
+ DBException,
+ ErrorCodes::InternalError);
+}
+
// Nothing can be greater than MaxKey so the resulting index bounds would be a useless empty range.
TEST_F(IndexBoundsBuilderTest, TranslateGtMaxKeyDoesNotGenerateBounds) {
auto testIndex = buildSimpleIndexEntry();