blob: 5a89720c1b94bd7dc8f16013917afbd8615c8127 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// @tags: [
// # The tenant migration override cannot deep copy very large or small dates.
// tenant_migration_incompatible,
// ]
(function() {
"use strict";
const coll = db.index_dates;
coll.drop();
// Min value for JS Date().
const d1 = new Date(-8640000000000000);
assert.commandWorked(coll.insert({_id: 1, d: d1}));
// Max value for JS Date().
const d2 = new Date(8640000000000000);
assert.commandWorked(coll.insert({_id: 2, d: d2}));
assert.commandWorked(coll.insert({_id: 3, d: 100}));
function test() {
const list = coll.find({d: {$type: "date"}}).sort({_id: 1}).toArray();
assert.eq(2, list.length);
assert.eq(list[0], {_id: 1, d: d1});
assert.eq(list[1], {_id: 2, d: d2});
}
test();
// Testing index version 1.
assert.commandWorked(coll.createIndex({d: 1}, {v: 1}));
test();
assert.commandWorked(coll.dropIndex({d: 1}));
// Testing index version 2.
assert.commandWorked(coll.createIndex({d: 1}));
test();
})();
|