diff options
author | Irina Yatsenko <irina.yatsenko@mongodb.com> | 2022-01-27 20:00:32 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-27 20:28:26 +0000 |
commit | 59e5b09e6840c5d00fbc961f812d66a00f823938 (patch) | |
tree | 5b5ebebe63576db309d378aff8b94f1c79b5ad02 /jstests/aggregation | |
parent | cd4b1025921a9ef28ce0e0466a18a849be4d80f1 (diff) | |
download | mongo-59e5b09e6840c5d00fbc961f812d66a00f823938.tar.gz |
SERVER-63017 Handle no arguments case in un-optimized agg operators
Diffstat (limited to 'jstests/aggregation')
-rw-r--r-- | jstests/aggregation/expressions/concat.js | 2 | ||||
-rw-r--r-- | jstests/aggregation/expressions/multiply.js | 1 | ||||
-rw-r--r-- | jstests/aggregation/expressions/set.js | 6 |
3 files changed, 9 insertions, 0 deletions
diff --git a/jstests/aggregation/expressions/concat.js b/jstests/aggregation/expressions/concat.js index 97e3a1a198d..cadfc2d4383 100644 --- a/jstests/aggregation/expressions/concat.js +++ b/jstests/aggregation/expressions/concat.js @@ -9,5 +9,7 @@ const coll = db.concat; coll.drop(); assert.commandWorked(coll.insert({})); + assert.eq(coll.findOne({}, {_id: false, "a": {$concat: [{$toLower: "$b"}]}}), {a: ""}); +assert.eq(coll.findOne({}, {_id: false, "a": {$concat: []}}), {a: ""}); })(); diff --git a/jstests/aggregation/expressions/multiply.js b/jstests/aggregation/expressions/multiply.js index 0743085565d..da4c612ff77 100644 --- a/jstests/aggregation/expressions/multiply.js +++ b/jstests/aggregation/expressions/multiply.js @@ -165,6 +165,7 @@ const nAryTestCases = [ {values: [undefined, 9223372036854, NumberDecimal(3.14)], expected: undefined}, {values: [NumberInt(2147483647), Infinity, NumberLong(-9223372036854)], expected: -Infinity}, {values: [-Infinity, NumberDecimal(-1.1), 1.0e+35], expected: NumberDecimal("Infinity")}, + {values: [], expected: 1}, ]; nAryTestCases.forEach(function(testCase) { diff --git a/jstests/aggregation/expressions/set.js b/jstests/aggregation/expressions/set.js index 6f378c3304c..4dbc19b32df 100644 --- a/jstests/aggregation/expressions/set.js +++ b/jstests/aggregation/expressions/set.js @@ -93,4 +93,10 @@ assert.eq(result.map(sortSetFields), [ equals: true }, ]); + +// No sets to union should produce an empty set for all records so we only check the first one. +assert.eq(coll.aggregate([{$project: {x: {$setUnion: []}}}]).toArray()[0]['x'], []); + +// No sets to intersect should produce an empty set for all records so we only check the first one. +assert.eq(coll.aggregate([{$project: {x: {$setIntersection: []}}}]).toArray()[0]['x'], []); }()); |