Files
mongo/jstests/aggregation/exec/undefined.js
Mihai Andrei eb8bef604c SERVER-99734 Finish moving top level tests in 'jstests/aggregation' into subdirectories (#31578)
GitOrigin-RevId: 2dd0c4d3698dfc4ccb1d7069d214aa6b66f28234
2025-02-03 16:27:34 +00:00

17 lines
578 B
JavaScript

// SERVER-4638 - this tests explicit undefined values
// This case is marked as a dup of SERVER-4674
const t = db[jsTestName()];
t.drop();
assert.commandWorked(t.insert({_id: 0, x: 0, undef: undefined}));
// Make sure having an undefined doesn't break pipelines not using the field
let res = t.aggregate({$project: {x: 1}}).toArray();
assert.eq(res[0].x, 0);
// Make sure having an undefined doesn't break pipelines that do use the field
res = t.aggregate({$project: {undef: 1}}).toArray();
assert.eq(res[0].undef, undefined);
assert.eq(typeof (res[0].undef), "undefined");