2012-06-29 15:22:44 -04:00
|
|
|
// SERVER-4638 - this tests explicit undefined values
|
|
|
|
|
// This case is marked as a dup of SERVER-4674
|
2012-01-06 12:11:32 -05:00
|
|
|
|
2025-01-22 14:40:22 -05:00
|
|
|
const t = db[jsTestName()];
|
2012-01-06 12:11:32 -05:00
|
|
|
t.drop();
|
|
|
|
|
|
2025-01-22 14:40:22 -05:00
|
|
|
assert.commandWorked(t.insert({_id: 0, x: 0, undef: undefined}));
|
2012-06-29 15:22:44 -04:00
|
|
|
|
2013-10-08 13:29:04 -04:00
|
|
|
// Make sure having an undefined doesn't break pipelines not using the field
|
2016-03-09 12:17:50 -05:00
|
|
|
let res = t.aggregate({$project: {x: 1}}).toArray();
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq(res[0].x, 0);
|
2012-01-06 12:11:32 -05:00
|
|
|
|
2013-10-08 13:29:04 -04:00
|
|
|
// Make sure having an undefined doesn't break pipelines that do use the field
|
2016-03-09 12:17:50 -05:00
|
|
|
res = t.aggregate({$project: {undef: 1}}).toArray();
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq(res[0].undef, undefined);
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.eq(typeof res[0].undef, "undefined");
|