Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make undefined sort same with with and w/o an index SERVER-635

  • Loading branch information...
commit 258fd02642ce228a816634915cce90842ed6d681 1 parent 1539083
@erh erh authored
Showing with 29 additions and 11 deletions.
  1. +1 −1  db/scanandorder.h
  2. +28 −10 jstests/sort6.js
View
2  db/scanandorder.h
@@ -40,7 +40,7 @@ namespace mongo {
// returns the key value for o
BSONObj getKeyFromObject(BSONObj o) {
- return o.extractFields(pattern);
+ return o.extractFields(pattern,true);
}
};
View
38 jstests/sort6.js
@@ -1,20 +1,38 @@
t = db.sort6;
-t.drop();
-
-t.insert({_id:1})
-t.insert({_id:2})
-t.insert({_id:3,c:1})
-t.insert({_id:4,c:2})
function get( x ){
return t.find().sort( { c : x } ).map( function(z){ return z._id; } );
}
-//assert.eq( [4,3,2,1] , get( -1 ) , "A1" )
-assert.eq( [1,2,3,4] , get( 1 ) , "A2" )
+// part 1
+t.drop();
+
+t.insert({_id:1,c:null})
+t.insert({_id:2,c:1})
+t.insert({_id:3,c:2})
+
+
+assert.eq( [3,2,1] , get( -1 ) , "A1" ) // SERVER-635
+assert.eq( [1,2,3] , get( 1 ) , "A2" )
+
+t.ensureIndex( { c : 1 } );
+
+assert.eq( [3,2,1] , get( -1 ) , "B1" )
+assert.eq( [1,2,3] , get( 1 ) , "B2" )
+
+
+// part 2
+t.drop();
+
+t.insert({_id:1})
+t.insert({_id:2,c:1})
+t.insert({_id:3,c:2})
+
+assert.eq( [3,2,1] , get( -1 ) , "C1" ) // SERVER-635
+assert.eq( [1,2,3] , get( 1 ) , "C2" )
t.ensureIndex( { c : 1 } );
-assert.eq( [4,3,2,1] , get( -1 ) , "B1" )
-assert.eq( [1,2,3,4] , get( 1 ) , "B2" )
+assert.eq( [3,2,1] , get( -1 ) , "D1" )
+assert.eq( [1,2,3] , get( 1 ) , "X2" )
Please sign in to comment.
Something went wrong with that request. Please try again.