summaryrefslogtreecommitdiff
path: root/jstests/sorta.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
committerAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
commit5d342a758c6095b4d30aba0750b54f13b8916f51 (patch)
tree762e9aa84781f5e3b96db2c02d356c29cf0217c0 /jstests/sorta.js
parentcbe2d992e9cd1ea66af9fa91df006106775d3073 (diff)
downloadmongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz
Imported Upstream version 2.0.0
Diffstat (limited to 'jstests/sorta.js')
-rw-r--r--jstests/sorta.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/sorta.js b/jstests/sorta.js
new file mode 100644
index 0000000..7c82778
--- /dev/null
+++ b/jstests/sorta.js
@@ -0,0 +1,26 @@
+// SERVER-2905 sorting with missing fields
+
+t = db.jstests_sorta;
+t.drop();
+
+// Enable _allow_dot to try and bypass v8 field name checking.
+t.insert( {_id:0,a:MinKey}, true );
+t.save( {_id:3,a:null} );
+t.save( {_id:1,a:[]} );
+t.save( {_id:7,a:[2]} );
+t.save( {_id:4} );
+t.save( {_id:5,a:null} );
+t.save( {_id:2,a:[]} );
+t.save( {_id:6,a:1} );
+t.insert( {_id:8,a:MaxKey}, true );
+
+function sorted( arr ) {
+ assert.eq( 9, arr.length );
+ for( i = 1; i < arr.length; ++i ) {
+ assert.lte( arr[ i-1 ]._id, arr[ i ]._id );
+ }
+}
+
+sorted( t.find().sort( {a:1} ).toArray() );
+t.ensureIndex( {a:1} );
+sorted( t.find().sort( {a:1} ).hint( {a:1} ).toArray() );