summaryrefslogtreecommitdiff
path: root/jstests/coveredIndex2.js
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-03-03 15:04:57 -0500
committerRandolph Tan <randolph@10gen.com>2014-03-03 15:29:00 -0500
commitf8534ae0d6c4e252d169c5bcf42f42cf6518ee7d (patch)
treee35db08d5d7ea3d70b6925f30bec0881efd2ee83 /jstests/coveredIndex2.js
parent6a10de0bb8fe996daca5ecd5687f1072abb0dd8b (diff)
downloadmongo-f8534ae0d6c4e252d169c5bcf42f42cf6518ee7d.tar.gz
SERVER-12127 migrate js tests to jscore suite when not related to writes
Temporarily put back jstest in order not to lose test coverage
Diffstat (limited to 'jstests/coveredIndex2.js')
-rw-r--r--jstests/coveredIndex2.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/jstests/coveredIndex2.js b/jstests/coveredIndex2.js
new file mode 100644
index 00000000000..56a23f43211
--- /dev/null
+++ b/jstests/coveredIndex2.js
@@ -0,0 +1,18 @@
+t = db["jstests_coveredIndex2"];
+t.drop();
+
+t.save({a: 1})
+t.save({a: 2})
+assert.eq( t.findOne({a: 1}).a, 1, "Cannot find right record" );
+assert.eq( t.count(), 2, "Not right length" );
+
+// use simple index
+t.ensureIndex({a: 1});
+assert.eq( t.find({a:1}).explain().indexOnly, false, "Find using covered index but all fields are returned");
+assert.eq( t.find({a:1}, {a: 1}).explain().indexOnly, false, "Find using covered index but _id is returned");
+assert.eq( t.find({a:1}, {a: 1, _id: 0}).explain().indexOnly, true, "Find is not using covered index");
+
+// add multikey
+t.save({a:[3,4]})
+assert.eq( t.find({a:1}, {a: 1, _id: 0}).explain().indexOnly, false, "Find is using covered index even after multikey insert");
+