summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorJess Balint <jbalint@gmail.com>2022-02-23 17:40:44 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-23 18:07:38 +0000
commit6889d8d80d0e69cc5c3de68eb05fe89e9b93cff4 (patch)
tree31b6c6beefb3c42be8c2faf735552354ba826a4c /jstests
parent5db2c8c6dadaa0b29c1de7cb5a133c34cfedf2d9 (diff)
downloadmongo-6889d8d80d0e69cc5c3de68eb05fe89e9b93cff4.tar.gz
SERVER-40691 $nin:[[],...] queries are not indexed
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/null_query_semantics.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/core/null_query_semantics.js b/jstests/core/null_query_semantics.js
index 2cdd7bc218d..ea03ba082ca 100644
--- a/jstests/core/null_query_semantics.js
+++ b/jstests/core/null_query_semantics.js
@@ -369,6 +369,41 @@ function testNullSemantics(coll) {
assert(resultsEq(projectResults, extractAValues(expected)), projectResults);
}());
+ // Test the semantics of the query {a: {$nin: [null, []]}}.
+ (function testNotInNullAndEmptyArrayQuery() {
+ const query = {a: {$nin: [null, []]}};
+ const noProjectResults = coll.find(query).toArray();
+ const expected = [
+ // Documents excluded by the query predicate are commented
+ // out below.
+ {_id: "a_empty_subobject", a: {}},
+ //{_id: "a_null", a: null},
+ {_id: "a_number", a: 4},
+ {_id: "a_subobject_b_not_null", a: {b: "hi"}},
+ {_id: "a_subobject_b_null", a: {b: null}},
+ {_id: "a_subobject_b_undefined", a: {b: undefined}},
+ //{_id: "a_undefined", a: undefined},
+ //{_id: "no_a"},
+
+ //{_id: "a_double_array", a: [[]]},
+ //{_id: "a_empty_array", a: []},
+ {_id: "a_object_array_all_b_nulls", a: [{b: null}, {b: undefined}, {b: null}, {}]},
+ {_id: "a_object_array_no_b_nulls", a: [{b: 1}, {b: 3}, {b: "string"}]},
+ {_id: "a_object_array_some_b_nulls", a: [{b: null}, {b: 3}, {b: null}]},
+ {_id: "a_object_array_some_b_undefined", a: [{b: undefined}, {b: 3}]},
+ {_id: "a_object_array_some_b_missing", a: [{b: 3}, {}]},
+ //{_id: "a_value_array_all_nulls", a: [null, null]},
+ {_id: "a_value_array_no_nulls", a: [1, "string", 4]},
+ //{_id: "a_value_array_with_null", a: [1, "string", null, 4]},
+ //{_id: "a_value_array_with_undefined", a: [1, "string", undefined, 4]},
+ ];
+
+ assert(resultsEq(noProjectResults, expected), noProjectResults);
+
+ const projectResults = coll.find(query, projectToOnlyA).toArray();
+ assert(resultsEq(projectResults, extractAValues(expected)), projectResults);
+ }());
+
(function testNotInNullAndRegexQuery() {
const query = {a: {$nin: [null, /^str.*/]}};
const noProjectResults = coll.find(query).toArray();