summaryrefslogtreecommitdiff
path: root/jstests/core/query/not/not3.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/query/not/not3.js')
-rw-r--r--jstests/core/query/not/not3.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/jstests/core/query/not/not3.js b/jstests/core/query/not/not3.js
new file mode 100644
index 00000000000..eac6bf8f047
--- /dev/null
+++ b/jstests/core/query/not/not3.js
@@ -0,0 +1,19 @@
+// Check that we return the correct results for negations over a
+// multikey index.
+
+var t = db.jstests_not3;
+t.drop();
+
+t.createIndex({arr: 1});
+t.save({_id: 0, arr: [1, 2, 3]});
+t.save({_id: 1, arr: [10, 11]});
+
+// Case 1: simple $ne over array field.
+var case1 = {arr: {$ne: 3}};
+assert.eq(1, t.find(case1).itcount(), "Case 1: wrong number of results");
+assert.eq(1, t.findOne(case1)._id, "Case 1: wrong _id");
+
+// Case 2: simple $not over array field.
+var case2 = {arr: {$not: {$gt: 6}}};
+assert.eq(1, t.find(case2).itcount(), "Case 2: wrong number of results");
+assert.eq(0, t.findOne(case2)._id, "Case 2: wrong _id");