Files
mongo/jstests/core/date2.js
Mathias Stearn f58fa5f78a Make BSONObj::woCompare a total ordering
Changes:
* Date and Timestamp are now distinct with all Dates before all Timestamps.
* Numeric comparisons now correctly handle Doubles and Long > 2**53.
* CodeWScope doesn't strcmp BSONObjs or strings which may contain NULs.

There should be no changes in any of the cases where woCompare defined a
correct total ordering before. The new behavior matches the ordering defined
by KeyString.

Related tickets:
* SERVER-3304 Error comparing Date and Timestamp
* SERVER-3719 Total ordering over Longs and Doubles
* SERVER-7804 CodeWScope comparisons are broken
* SERVER-16632 Change WiredTiger index key format

Changes to the comparison function for aggregation will be handled separately
as SERVER-16708.
2015-01-07 11:56:33 -05:00

12 lines
354 B
JavaScript

// Check that it's possible to compare a Date to a Timestamp, but they are never equal - SERVER-3304
t = db.jstests_date2;
t.drop();
t.ensureIndex( {a:1} );
var obj = {a:new Timestamp(0, 1)}; // in old versions this was == to new Date(1)
t.save( obj );
assert.eq( 0, t.find( {a:{$gt:new Date(1)}} ).itcount() );
assert.eq( 1, t.find(obj).itcount() );