summaryrefslogtreecommitdiff
path: root/jstests/core/query/array/arrayfind4.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/query/array/arrayfind4.js')
-rw-r--r--jstests/core/query/array/arrayfind4.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/core/query/array/arrayfind4.js b/jstests/core/query/array/arrayfind4.js
new file mode 100644
index 00000000000..2d7c0e03668
--- /dev/null
+++ b/jstests/core/query/array/arrayfind4.js
@@ -0,0 +1,26 @@
+// @tags: [
+// requires_non_retryable_writes,
+// ]
+
+// Test query empty array SERVER-2258
+
+t = db.jstests_arrayfind4;
+t.drop();
+
+t.save({a: []});
+t.createIndex({a: 1});
+
+assert.eq(1, t.find({a: []}).hint({$natural: 1}).itcount());
+assert.eq(1, t.find({a: []}).hint({a: 1}).itcount());
+
+assert.eq(1, t.find({a: {$in: [[]]}}).hint({$natural: 1}).itcount());
+assert.eq(1, t.find({a: {$in: [[]]}}).hint({a: 1}).itcount());
+
+t.remove({});
+t.save({a: [[]]});
+
+assert.eq(1, t.find({a: []}).hint({$natural: 1}).itcount());
+assert.eq(1, t.find({a: []}).hint({a: 1}).itcount());
+
+assert.eq(1, t.find({a: {$in: [[]]}}).hint({$natural: 1}).itcount());
+assert.eq(1, t.find({a: {$in: [[]]}}).hint({a: 1}).itcount());