summaryrefslogtreecommitdiff
path: root/jstests/core/covered_index_sort_2.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/covered_index_sort_2.js')
-rw-r--r--jstests/core/covered_index_sort_2.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/jstests/core/covered_index_sort_2.js b/jstests/core/covered_index_sort_2.js
new file mode 100644
index 00000000000..e5dd48b47af
--- /dev/null
+++ b/jstests/core/covered_index_sort_2.js
@@ -0,0 +1,17 @@
+// Simple covered index query test with sort on _id
+
+var coll = db.getCollection("covered_sort_2")
+coll.drop()
+for (i=0;i<10;i++) {
+ coll.insert({_id:i})
+}
+coll.insert({_id:"1"})
+coll.insert({_id:{bar:1}})
+coll.insert({_id:null})
+
+// Test no query
+var plan = coll.find({}, {_id:1}).sort({_id:-1}).hint({_id:1}).explain()
+assert.eq(true, plan.indexOnly, "sort.2.1 - indexOnly should be true on covered query")
+assert.eq(0, plan.nscannedObjects, "sort.2.1 - nscannedObjects should be 0 for covered query")
+
+print ('all tests pass') \ No newline at end of file