summaryrefslogtreecommitdiff
path: root/jstests/aggregation/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/aggregation/bugs')
-rw-r--r--jstests/aggregation/bugs/cond.js25
-rw-r--r--jstests/aggregation/bugs/firstlast.js16
-rw-r--r--jstests/aggregation/bugs/match.js14
-rw-r--r--jstests/aggregation/bugs/server10176.js43
-rw-r--r--jstests/aggregation/bugs/server11118.js58
-rw-r--r--jstests/aggregation/bugs/server11675.js78
-rw-r--r--jstests/aggregation/bugs/server12015.js5
-rw-r--r--jstests/aggregation/bugs/server14670.js4
-rw-r--r--jstests/aggregation/bugs/server17943.js46
-rw-r--r--jstests/aggregation/bugs/server18198.js8
-rw-r--r--jstests/aggregation/bugs/server18222.js7
-rw-r--r--jstests/aggregation/bugs/server19095.js174
-rw-r--r--jstests/aggregation/bugs/server20163.js109
-rw-r--r--jstests/aggregation/bugs/server20169.js16
-rw-r--r--jstests/aggregation/bugs/server21632.js5
-rw-r--r--jstests/aggregation/bugs/server22093.js5
-rw-r--r--jstests/aggregation/bugs/server22580.js12
-rw-r--r--jstests/aggregation/bugs/server3253.js16
-rw-r--r--jstests/aggregation/bugs/server4588.js16
-rw-r--r--jstests/aggregation/bugs/server5044.js12
-rw-r--r--jstests/aggregation/bugs/server6121.js30
-rw-r--r--jstests/aggregation/bugs/server6125.js4
-rw-r--r--jstests/aggregation/bugs/server6131.js36
-rw-r--r--jstests/aggregation/bugs/server6179.js8
-rw-r--r--jstests/aggregation/bugs/server6189.js86
-rw-r--r--jstests/aggregation/bugs/server6190.js5
-rw-r--r--jstests/aggregation/bugs/server6195.js2
-rw-r--r--jstests/aggregation/bugs/server6529.js14
-rw-r--r--jstests/aggregation/bugs/server6531.js8
-rw-r--r--jstests/aggregation/bugs/server6556.js12
-rw-r--r--jstests/aggregation/bugs/server7781.js12
-rw-r--r--jstests/aggregation/bugs/server9840.js109
-rw-r--r--jstests/aggregation/bugs/server9841.js25
-rw-r--r--jstests/aggregation/bugs/substr.js26
-rw-r--r--jstests/aggregation/bugs/upperlower.js5
35 files changed, 454 insertions, 597 deletions
diff --git a/jstests/aggregation/bugs/cond.js b/jstests/aggregation/bugs/cond.js
index 2b4fa8ff16e..c48c6b724f0 100644
--- a/jstests/aggregation/bugs/cond.js
+++ b/jstests/aggregation/bugs/cond.js
@@ -68,16 +68,15 @@ t.save({noonSense: 'pm', mealCombined: 'yes'});
t.save({noonSense: 'pm', mealCombined: 'no'});
assert.eq(['breakfast', 'brunch', 'linner', 'dinner'],
t.aggregate({
- $project: {
- a: {
- $cond: [
- {$eq: ['$noonSense', 'am']},
- {$cond: [{$eq: ['$mealCombined', 'yes']}, 'brunch', 'breakfast']},
- {$cond: [{$eq: ['$mealCombined', 'yes']}, 'linner', 'dinner']}
- ]
- }
- }
- })
- .map(function(x) {
- return x.a;
- }));
+ $project: {
+ a: {
+ $cond: [
+ {$eq: ['$noonSense', 'am']},
+ {$cond: [{$eq: ['$mealCombined', 'yes']}, 'brunch', 'breakfast']},
+ {$cond: [{$eq: ['$mealCombined', 'yes']}, 'linner', 'dinner']}
+ ]
+ }
+ }
+ }).map(function(x) {
+ return x.a;
+ }));
diff --git a/jstests/aggregation/bugs/firstlast.js b/jstests/aggregation/bugs/firstlast.js
index ca9e963f6ca..54f0f8be0e9 100644
--- a/jstests/aggregation/bugs/firstlast.js
+++ b/jstests/aggregation/bugs/firstlast.js
@@ -104,17 +104,5 @@ assertFirstLast([1, 2], [6], [], '$b.c');
t.drop();
t.save({a: 1, b: 1});
t.save({a: 1, b: 2});
-assertFirstLast(1,
- 0,
- [],
- {
-$mod:
- ['$b', 2]
- });
-assertFirstLast(0,
- 1,
- [],
- {
-$mod:
- [{$add: ['$b', 1]}, 2]
- });
+assertFirstLast(1, 0, [], {$mod: ['$b', 2]});
+assertFirstLast(0, 1, [], {$mod: [{$add: ['$b', 1]}, 2]});
diff --git a/jstests/aggregation/bugs/match.js b/jstests/aggregation/bugs/match.js
index fbc467812d7..2ee646dac7e 100644
--- a/jstests/aggregation/bugs/match.js
+++ b/jstests/aggregation/bugs/match.js
@@ -13,9 +13,7 @@ identityProjection = {
/** Assert that an aggregation generated the expected error. */
function assertError(expectedCode, matchSpec) {
- matchStage = {
- $match: matchSpec
- };
+ matchStage = {$match: matchSpec};
// Check where matching is folded in to DocumentSourceCursor.
assertErrorCode(t, [matchStage], expectedCode);
// Check where matching is not folded in to DocumentSourceCursor.
@@ -41,9 +39,7 @@ function assertResults(expectedResults, matchSpec) {
if (expectedResults) {
assertEqualResultsUnordered(expectedResults, findResults);
}
- matchStage = {
- $match: matchSpec
- };
+ matchStage = {$match: matchSpec};
// Check where matching is folded in to DocumentSourceCursor.
assertEqualResultsUnordered(findResults, t.aggregate(matchStage).toArray());
// Check where matching is not folded in to DocumentSourceCursor.
@@ -176,11 +172,7 @@ function checkMatchResults(indexed) {
// $and
assertResults([{_id: 1, a: 2}], {$and: [{a: 2}, {_id: 1}]});
- assertResults([],
- {
- $and:
- [{a: 1}, {_id: 1}]
- });
+ assertResults([], {$and: [{a: 1}, {_id: 1}]});
assertResults([{_id: 1, a: 2}, {_id: 2, a: 3}],
{$and: [{$or: [{_id: 1}, {a: 3}]}, {$or: [{_id: 2}, {a: 2}]}]});
diff --git a/jstests/aggregation/bugs/server10176.js b/jstests/aggregation/bugs/server10176.js
index 5a56585265d..b04db0c4319 100644
--- a/jstests/aggregation/bugs/server10176.js
+++ b/jstests/aggregation/bugs/server10176.js
@@ -33,28 +33,27 @@ load('jstests/aggregation/extras/utils.js');
// valid use of $abs: numbers become positive, null/undefined/nonexistent become null
var results = coll.aggregate([{$project: {a: {$abs: "$a"}}}]).toArray();
- assert.eq(results,
- [
- {_id: 0, a: 5},
- {_id: 1, a: 5},
- {_id: 2, a: 5.5},
- {_id: 3, a: 5.5},
- {_id: 4, a: 5},
- {_id: 5, a: 5},
- {_id: 6, a: NumberLong("5")},
- {_id: 7, a: NumberLong("5")},
- {_id: 8, a: 0},
- {_id: 9, a: 0},
- {_id: 10, a: 0},
- {_id: 11, a: NumberLong(Math.pow(2, 31))},
- {_id: 12, a: Math.pow(2, 31)},
- {_id: 13, a: NumberLong("1152921504606846977")},
- {_id: 14, a: NumberLong("1152921504606846977")},
- {_id: 15, a: null},
- {_id: 16, a: null},
- {_id: 17, a: NaN},
- {_id: 18, a: null},
- ]);
+ assert.eq(results, [
+ {_id: 0, a: 5},
+ {_id: 1, a: 5},
+ {_id: 2, a: 5.5},
+ {_id: 3, a: 5.5},
+ {_id: 4, a: 5},
+ {_id: 5, a: 5},
+ {_id: 6, a: NumberLong("5")},
+ {_id: 7, a: NumberLong("5")},
+ {_id: 8, a: 0},
+ {_id: 9, a: 0},
+ {_id: 10, a: 0},
+ {_id: 11, a: NumberLong(Math.pow(2, 31))},
+ {_id: 12, a: Math.pow(2, 31)},
+ {_id: 13, a: NumberLong("1152921504606846977")},
+ {_id: 14, a: NumberLong("1152921504606846977")},
+ {_id: 15, a: null},
+ {_id: 16, a: null},
+ {_id: 17, a: NaN},
+ {_id: 18, a: null},
+ ]);
// Invalid
// using $abs on string
diff --git a/jstests/aggregation/bugs/server11118.js b/jstests/aggregation/bugs/server11118.js
index da4e9862bad..3d2813ed8ae 100644
--- a/jstests/aggregation/bugs/server11118.js
+++ b/jstests/aggregation/bugs/server11118.js
@@ -9,9 +9,13 @@ function testFormat(date, formatStr, expectedStr) {
db.dates.drop();
db.dates.insert({date: date});
- var res = db.dates.aggregate([{
- $project: {_id: 0, formatted: {$dateToString: {format: formatStr, date: "$date"}}}
- }]).toArray();
+ var res =
+ db.dates
+ .aggregate([{
+ $project:
+ {_id: 0, formatted: {$dateToString: {format: formatStr, date: "$date"}}}
+ }])
+ .toArray();
assert.eq(res[0].formatted, expectedStr);
}
@@ -36,18 +40,16 @@ function testDateValueError(dateVal, errCode) {
var now = ISODate();
// Use all modifiers we can test with js provided function
-testFormat(now,
- "%%-%Y-%m-%d-%H-%M-%S-%L",
- [
- "%",
- now.getUTCFullYear().zeroPad(4),
- (now.getUTCMonth() + 1).zeroPad(2),
- now.getUTCDate().zeroPad(2),
- now.getUTCHours().zeroPad(2),
- now.getUTCMinutes().zeroPad(2),
- now.getUTCSeconds().zeroPad(2),
- now.getUTCMilliseconds().zeroPad(3)
- ].join("-"));
+testFormat(now, "%%-%Y-%m-%d-%H-%M-%S-%L", [
+ "%",
+ now.getUTCFullYear().zeroPad(4),
+ (now.getUTCMonth() + 1).zeroPad(2),
+ now.getUTCDate().zeroPad(2),
+ now.getUTCHours().zeroPad(2),
+ now.getUTCMinutes().zeroPad(2),
+ now.getUTCSeconds().zeroPad(2),
+ now.getUTCMilliseconds().zeroPad(3)
+].join("-"));
// Padding tests
var padme = ISODate("2001-02-03T04:05:06.007Z");
@@ -62,20 +64,18 @@ testFormat(padme, "%S", padme.getUTCSeconds().zeroPad(2));
testFormat(padme, "%L", padme.getUTCMilliseconds().zeroPad(3));
// no space and multiple characters between modifiers
-testFormat(now,
- "%d%d***%d***%d**%d*%d",
- [
- now.getUTCDate().zeroPad(2),
- now.getUTCDate().zeroPad(2),
- "***",
- now.getUTCDate().zeroPad(2),
- "***",
- now.getUTCDate().zeroPad(2),
- "**",
- now.getUTCDate().zeroPad(2),
- "*",
- now.getUTCDate().zeroPad(2)
- ].join(""));
+testFormat(now, "%d%d***%d***%d**%d*%d", [
+ now.getUTCDate().zeroPad(2),
+ now.getUTCDate().zeroPad(2),
+ "***",
+ now.getUTCDate().zeroPad(2),
+ "***",
+ now.getUTCDate().zeroPad(2),
+ "**",
+ now.getUTCDate().zeroPad(2),
+ "*",
+ now.getUTCDate().zeroPad(2)
+].join(""));
// JS doesn't have equivalents of these format specifiers
testFormat(ISODate('1999-01-02 03:04:05.006Z'), "%U-%w-%j", "00-7-002");
diff --git a/jstests/aggregation/bugs/server11675.js b/jstests/aggregation/bugs/server11675.js
index 709120c27ca..a38570dc8cd 100644
--- a/jstests/aggregation/bugs/server11675.js
+++ b/jstests/aggregation/bugs/server11675.js
@@ -88,57 +88,57 @@ var server11675 = function() {
return obj;
});
var res = t.aggregate([
- {$match: {$text: {$search: 'apple banana'}}},
- {$sort: {textScore: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {$text: {$search: 'apple banana'}}},
+ {$sort: {textScore: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res, findRes);
// Make sure {$meta: 'textScore'} can be used as a sub-expression
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {
- $project: {
- words: 1,
- score: {$meta: 'textScore'},
- wordsTimesScore: {$multiply: ['$words', {$meta: 'textScore'}]}
- }
- }
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {
+ $project: {
+ words: 1,
+ score: {$meta: 'textScore'},
+ wordsTimesScore: {$multiply: ['$words', {$meta: 'textScore'}]}
+ }
+ }
+ ]).toArray();
assert.eq(res[0].wordsTimesScore, res[0].words * res[0].score, tojson(res));
// And can be used in $group
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple banana'}}},
- {$group: {_id: {$meta: 'textScore'}, score: {$first: {$meta: 'textScore'}}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple banana'}}},
+ {$group: {_id: {$meta: 'textScore'}, score: {$first: {$meta: 'textScore'}}}}
+ ]).toArray();
assert.eq(res[0]._id, res[0].score, tojson(res));
// Make sure metadata crosses shard -> merger boundary
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {$project: {scoreOnShard: {$meta: 'textScore'}}},
- {$limit: 1} // force a split. later stages run on merger
- ,
- {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {$project: {scoreOnShard: {$meta: 'textScore'}}},
+ {$limit: 1} // force a split. later stages run on merger
+ ,
+ {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res[0].scoreOnMerger, res[0].scoreOnShard);
var score = res[0].scoreOnMerger; // save for later tests
// Make sure metadata crosses shard -> merger boundary even if not used on shard
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {$limit: 1} // force a split. later stages run on merger
- ,
- {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {$limit: 1} // force a split. later stages run on merger
+ ,
+ {$project: {scoreOnShard: 1, scoreOnMerger: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res[0].scoreOnMerger, score);
// Make sure metadata works if first $project doesn't use it.
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple'}}},
- {$project: {_id: 1}},
- {$project: {_id: 1, score: {$meta: 'textScore'}}}
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple'}}},
+ {$project: {_id: 1}},
+ {$project: {_id: 1, score: {$meta: 'textScore'}}}
+ ]).toArray();
assert.eq(res[0].score, score);
// Make sure the metadata is 'missing()' when it doesn't exist because it was never created
@@ -147,20 +147,20 @@ var server11675 = function() {
// Make sure the metadata is 'missing()' when it doesn't exist because the document changed
var res = t.aggregate([
- {$match: {_id: 1, $text: {$search: 'apple banana'}}},
- {$group: {_id: 1, score: {$first: {$meta: 'textScore'}}}},
- {$project: {_id: 1, scoreAgain: {$meta: 'textScore'}}},
- ]).toArray();
+ {$match: {_id: 1, $text: {$search: 'apple banana'}}},
+ {$group: {_id: 1, score: {$first: {$meta: 'textScore'}}}},
+ {$project: {_id: 1, scoreAgain: {$meta: 'textScore'}}},
+ ]).toArray();
assert(!("scoreAgain" in res[0]));
// Make sure metadata works after a $unwind
t.insert({_id: 5, text: 'mango', words: [1, 2, 3]});
var res = t.aggregate([
- {$match: {$text: {$search: 'mango'}}},
- {$project: {score: {$meta: "textScore"}, _id: 1, words: 1}},
- {$unwind: '$words'},
- {$project: {scoreAgain: {$meta: "textScore"}, score: 1}}
- ]).toArray();
+ {$match: {$text: {$search: 'mango'}}},
+ {$project: {score: {$meta: "textScore"}, _id: 1, words: 1}},
+ {$unwind: '$words'},
+ {$project: {scoreAgain: {$meta: "textScore"}, score: 1}}
+ ]).toArray();
assert.eq(res[0].scoreAgain, res[0].score);
// Error checking
diff --git a/jstests/aggregation/bugs/server12015.js b/jstests/aggregation/bugs/server12015.js
index af4ee75f92d..c237e4f6f90 100644
--- a/jstests/aggregation/bugs/server12015.js
+++ b/jstests/aggregation/bugs/server12015.js
@@ -12,10 +12,7 @@ load("jstests/aggregation/extras/utils.js"); // For orderedArrayEq.
"use strict";
var coll = db.server12015;
coll.drop();
- var indexSpec = {
- a: 1,
- b: 1
- };
+ var indexSpec = {a: 1, b: 1};
assert.writeOK(coll.insert({_id: 0, a: 0, b: 0}));
assert.writeOK(coll.insert({_id: 1, a: 0, b: 1}));
diff --git a/jstests/aggregation/bugs/server14670.js b/jstests/aggregation/bugs/server14670.js
index 92c6e98e8e1..dc8a750e9db 100644
--- a/jstests/aggregation/bugs/server14670.js
+++ b/jstests/aggregation/bugs/server14670.js
@@ -12,12 +12,12 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
coll.insert({});
assertErrorCode(coll,
- [{$project: {strLen: {$strLenBytes: 1}}}],
+ [{$project: {strLen: {$strLenBytes: 1}}}],
34473,
"$strLenBytes requires a string argument.");
assertErrorCode(coll,
- [{$project: {strLen: {$strLenCP: 1}}}],
+ [{$project: {strLen: {$strLenCP: 1}}}],
34471,
"$strLenCP requires a string argument.");
}());
diff --git a/jstests/aggregation/bugs/server17943.js b/jstests/aggregation/bugs/server17943.js
index 10dbac2c37a..7036a16b940 100644
--- a/jstests/aggregation/bugs/server17943.js
+++ b/jstests/aggregation/bugs/server17943.js
@@ -18,11 +18,7 @@ load('jstests/aggregation/extras/utils.js');
assert.writeOK(coll.insert({_id: 6}));
// Create filter to only accept odd numbers.
- filterDoc = {
- input: '$a',
- as: 'x',
- cond: {$eq: [1, {$mod: ['$$x', 2]}]}
- };
+ filterDoc = {input: '$a', as: 'x', cond: {$eq: [1, {$mod: ['$$x', 2]}]}};
var expectedResults = [
{_id: 0, b: [1, 3, 5]},
{_id: 1, b: []},
@@ -45,57 +41,31 @@ load('jstests/aggregation/extras/utils.js');
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28646);
// Extra field(s).
- filterDoc = {
- input: '$a',
- as: 'x',
- cond: true,
- extra: 1
- };
+ filterDoc = {input: '$a', as: 'x', cond: true, extra: 1};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28647);
// Missing 'input'.
- filterDoc = {
- as: 'x',
- cond: true
- };
+ filterDoc = {as: 'x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28648);
// Missing 'as'.
- filterDoc = {
- input: '$a',
- cond: true
- };
+ filterDoc = {input: '$a', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28649);
// Missing 'cond'.
- filterDoc = {
- input: '$a',
- as: 'x'
- };
+ filterDoc = {input: '$a', as: 'x'};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28650);
// 'as' is not a valid variable name.
- filterDoc = {
- input: '$a',
- as: '$x',
- cond: true
- };
+ filterDoc = {input: '$a', as: '$x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 16867);
// 'input' is not an array.
- filterDoc = {
- input: 'string',
- as: 'x',
- cond: true
- };
+ filterDoc = {input: 'string', as: 'x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28651);
coll.drop();
assert.writeOK(coll.insert({a: 'string'}));
- filterDoc = {
- input: '$a',
- as: 'x',
- cond: true
- };
+ filterDoc = {input: '$a', as: 'x', cond: true};
assertErrorCode(coll, [{$project: {b: {$filter: filterDoc}}}], 28651);
}());
diff --git a/jstests/aggregation/bugs/server18198.js b/jstests/aggregation/bugs/server18198.js
index 39cb37074e5..19b355f4953 100644
--- a/jstests/aggregation/bugs/server18198.js
+++ b/jstests/aggregation/bugs/server18198.js
@@ -16,14 +16,10 @@
},
runCommand: function(db, cmd, opts) {
commandsRan.push({db: db, cmd: cmd, opts: opts});
- return {
- ok: 1.0
- };
+ return {ok: 1.0};
},
getReadPref: function() {
- return {
- mode: "secondaryPreferred"
- };
+ return {mode: "secondaryPreferred"};
},
getReadPrefMode: function() {
return "secondaryPreferred";
diff --git a/jstests/aggregation/bugs/server18222.js b/jstests/aggregation/bugs/server18222.js
index 1a46ff349c8..cea52b3970d 100644
--- a/jstests/aggregation/bugs/server18222.js
+++ b/jstests/aggregation/bugs/server18222.js
@@ -20,8 +20,11 @@
assert.writeOK(coll.insert({_id: 10, x: ['0']}));
// Project field is_array to represent whether the field x was an array.
- var results =
- coll.aggregate([{$sort: {_id: 1}}, {$project: {isArray: {$isArray: '$x'}}}, ]).toArray();
+ var results = coll.aggregate([
+ {$sort: {_id: 1}},
+ {$project: {isArray: {$isArray: '$x'}}},
+ ])
+ .toArray();
var expectedResults = [
{_id: 0, isArray: false},
{_id: 1, isArray: false},
diff --git a/jstests/aggregation/bugs/server19095.js b/jstests/aggregation/bugs/server19095.js
index 30d2610aad9..875a7d16a9d 100644
--- a/jstests/aggregation/bugs/server19095.js
+++ b/jstests/aggregation/bugs/server19095.js
@@ -55,11 +55,10 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, a: null, "same": [{_id: 1, b: null}, {_id: 2}]},
{_id: 2, "same": [{_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([{
- $lookup: {localField: "nonexistent", foreignField: "b", from: "from", as: "same"}
- }],
- expectedResults,
- coll);
+ testPipeline(
+ [{$lookup: {localField: "nonexistent", foreignField: "b", from: "from", as: "same"}}],
+ expectedResults,
+ coll);
// If foreignField is nonexistent, it is treated as if it is null.
expectedResults = [
@@ -67,25 +66,22 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, a: null, "same": [{_id: 0, b: 1}, {_id: 1, b: null}, {_id: 2}]},
{_id: 2, "same": [{_id: 0, b: 1}, {_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([{
- $lookup: {localField: "a", foreignField: "nonexistent", from: "from", as: "same"}
- }],
- expectedResults,
- coll);
+ testPipeline(
+ [{$lookup: {localField: "a", foreignField: "nonexistent", from: "from", as: "same"}}],
+ expectedResults,
+ coll);
// If there are no matches or the from coll doesn't exist, the result is an empty array.
expectedResults =
[{_id: 0, a: 1, "same": []}, {_id: 1, a: null, "same": []}, {_id: 2, "same": []}];
- testPipeline([{
- $lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}
- }],
- expectedResults,
- coll);
- testPipeline([{
- $lookup: {localField: "a", foreignField: "b", from: "nonexistent", as: "same"}
- }],
- expectedResults,
- coll);
+ testPipeline(
+ [{$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}}],
+ expectedResults,
+ coll);
+ testPipeline(
+ [{$lookup: {localField: "a", foreignField: "b", from: "nonexistent", as: "same"}}],
+ expectedResults,
+ coll);
// If field name specified by "as" already exists, it is overwritten.
expectedResults = [
@@ -106,13 +102,14 @@ load("jstests/aggregation/extras/utils.js");
},
{_id: 2, "c": [{_id: 1, b: null}, {_id: 2}], "d": [{_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "c"}},
- {$project: {"a": 1, "c": 1}},
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "d"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "c"}},
+ {$project: {"a": 1, "c": 1}},
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "d"}}
+ ],
+ expectedResults,
+ coll);
//
// Coalescing with $unwind.
@@ -126,12 +123,13 @@ load("jstests/aggregation/extras/utils.js");
{_id: 2, same: {_id: 1, b: null}},
{_id: 2, same: {_id: 2}}
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
- {$unwind: {path: "$same"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
+ {$unwind: {path: "$same"}}
+ ],
+ expectedResults,
+ coll);
// An $unwind on the "as" field, with includeArrayIndex.
expectedResults = [
@@ -141,39 +139,51 @@ load("jstests/aggregation/extras/utils.js");
{_id: 2, same: {_id: 1, b: null}, index: NumberLong(0)},
{_id: 2, same: {_id: 2}, index: NumberLong(1)},
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
- {$unwind: {path: "$same", includeArrayIndex: "index"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
+ {$unwind: {path: "$same", includeArrayIndex: "index"}}
+ ],
+ expectedResults,
+ coll);
// Normal $unwind with no matching documents.
expectedResults = [];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
- {$unwind: {path: "$same"}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
+ {$unwind: {path: "$same"}}
+ ],
+ expectedResults,
+ coll);
// $unwind with preserveNullAndEmptyArray with no matching documents.
- expectedResults = [{_id: 0, a: 1}, {_id: 1, a: null}, {_id: 2}, ];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
- {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
- ],
- expectedResults,
- coll);
+ expectedResults = [
+ {_id: 0, a: 1},
+ {_id: 1, a: null},
+ {_id: 2},
+ ];
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "nonexistent", from: "from", as: "same"}},
+ {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
+ ],
+ expectedResults,
+ coll);
// $unwind with preserveNullAndEmptyArray, some with matching documents, some without.
- expectedResults = [{_id: 0, a: 1}, {_id: 1, a: null, same: {_id: 0, b: 1}}, {_id: 2}, ];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
- {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
- ],
- expectedResults,
- coll);
+ expectedResults = [
+ {_id: 0, a: 1},
+ {_id: 1, a: null, same: {_id: 0, b: 1}},
+ {_id: 2},
+ ];
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
+ {$unwind: {path: "$same", preserveNullAndEmptyArrays: true}}
+ ],
+ expectedResults,
+ coll);
// $unwind with preserveNullAndEmptyArray and includeArrayIndex, some with matching
// documents, some without.
@@ -182,15 +192,16 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, a: null, same: {_id: 0, b: 1}, index: NumberLong(0)},
{_id: 2, index: null},
];
- testPipeline([
- {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
- {
- $unwind:
- {path: "$same", preserveNullAndEmptyArrays: true, includeArrayIndex: "index"}
- }
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "_id", foreignField: "b", from: "from", as: "same"}},
+ {
+ $unwind:
+ {path: "$same", preserveNullAndEmptyArrays: true, includeArrayIndex: "index"}
+ }
+ ],
+ expectedResults,
+ coll);
//
// Dependencies.
@@ -203,12 +214,13 @@ load("jstests/aggregation/extras/utils.js");
{_id: 1, "same": [{_id: 1, b: null}, {_id: 2}]},
{_id: 2, "same": [{_id: 1, b: null}, {_id: 2}]}
];
- testPipeline([
- {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
- {$project: {"same": 1}}
- ],
- expectedResults,
- coll);
+ testPipeline(
+ [
+ {$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}},
+ {$project: {"same": 1}}
+ ],
+ expectedResults,
+ coll);
//
// Dotted field paths.
@@ -277,12 +289,7 @@ load("jstests/aggregation/extras/utils.js");
}
];
expectedResults = [
- {
- _id: 0,
- a: {b: 1},
- same: {documents: {_id: 0, target: 1}},
- c: {d: {e: NumberLong(0)}}
- },
+ {_id: 0, a: {b: 1}, same: {documents: {_id: 0, target: 1}}, c: {d: {e: NumberLong(0)}}},
{_id: 1, same: {}, c: {d: {e: null}}},
];
testPipeline(pipeline, expectedResults, coll);
@@ -401,9 +408,8 @@ load("jstests/aggregation/extras/utils.js");
// An error is thrown if the from collection is sharded.
assert(sharded.adminCommand({shardCollection: "test.from", key: {_id: 1}}));
- assertErrorCode(
- sharded.getDB('test').lookUp,
- [{$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}}],
- 28769);
+ assertErrorCode(sharded.getDB('test').lookUp,
+ [{$lookup: {localField: "a", foreignField: "b", from: "from", as: "same"}}],
+ 28769);
sharded.stop();
}());
diff --git a/jstests/aggregation/bugs/server20163.js b/jstests/aggregation/bugs/server20163.js
index 501a6cc546a..e61ba606c24 100644
--- a/jstests/aggregation/bugs/server20163.js
+++ b/jstests/aggregation/bugs/server20163.js
@@ -12,182 +12,127 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
var zipObj = 3;
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34460,
"$zip requires an object" + " as an argument.");
- zipObj = {
- inputs: []
- };
+ zipObj = {inputs: []};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34465,
"$zip requires at least" + " one input array");
- zipObj = {
- inputs: {"a": "b"}
- };
+ zipObj = {inputs: {"a": "b"}};
assertErrorCode(coll, [{$project: {zipped: {$zip: zipObj}}}], 34461, "inputs is not an array");
- zipObj = {
- inputs: ["$a"],
- defaults: ["A"]
- };
+ zipObj = {inputs: ["$a"], defaults: ["A"]};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34466,
"cannot specify defaults" + " unless useLongestLength is true.");
- zipObj = {
- inputs: ["$a"],
- defaults: ["A", "B"],
- useLongestLength: true
- };
+ zipObj = {inputs: ["$a"], defaults: ["A", "B"], useLongestLength: true};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34467,
"inputs and defaults" + " must be the same length.");
- zipObj = {
- inputs: ["$a"],
- defaults: {"a": "b"}
- };
+ zipObj = {inputs: ["$a"], defaults: {"a": "b"}};
assertErrorCode(
coll, [{$project: {zipped: {$zip: zipObj}}}], 34462, "defaults is not an" + " array");
- zipObj = {
- inputs: ["$a"],
- defaults: ["A"],
- useLongestLength: 1
- };
+ zipObj = {inputs: ["$a"], defaults: ["A"], useLongestLength: 1};
assertErrorCode(
coll, [{$project: {zipped: {$zip: zipObj}}}], 34463, "useLongestLength is not" + " a bool");
- zipObj = {
- inputs: ["$a", "$b"],
- defaults: ["A"],
- notAField: 1
- };
+ zipObj = {inputs: ["$a", "$b"], defaults: ["A"], notAField: 1};
assertErrorCode(coll, [{$project: {zipped: {$zip: zipObj}}}], 34464, "unknown argument");
- zipObj = {
- inputs: ["A", "B"]
- };
+ zipObj = {inputs: ["A", "B"]};
assertErrorCode(coll,
- [{$project: {zipped: {$zip: zipObj}}}],
+ [{$project: {zipped: {$zip: zipObj}}}],
34468,
"an element of inputs" + " was not an array.");
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B", "C"]]
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B", "C"]]};
var res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
var output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, "A"], [2, "B"], [3, "C"]]);
- zipObj = {
- inputs: [[1, 2, 3], null]
- };
+ zipObj = {inputs: [[1, 2, 3], null]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: [null, [1, 2, 3]]
- };
+ zipObj = {inputs: [null, [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: ["$missing", [1, 2, 3]]
- };
+ zipObj = {inputs: ["$missing", [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: [undefined, [1, 2, 3]]
- };
+ zipObj = {inputs: [undefined, [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, null);
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B"]]
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B"]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, "A"], [2, "B"]]);
- zipObj = {
- inputs: [["A", "B"], [1, 2, 3]]
- };
+ zipObj = {inputs: [["A", "B"], [1, 2, 3]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [["A", 1], ["B", 2]]);
- zipObj = {
- inputs: [[], []]
- };
+ zipObj = {inputs: [[], []]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, []);
- zipObj = {
- inputs: [["$short"], ["$long"]]
- };
+ zipObj = {inputs: [["$short"], ["$long"]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[['x', 'y'], [1, 2, 3]]]);
- zipObj = {
- inputs: ["$short", "$long"]
- };
+ zipObj = {inputs: ["$short", "$long"]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [['x', 1], ['y', 2]]);
- zipObj = {
- inputs: [["$long"]]
- };
+ zipObj = {inputs: [["$long"]]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[[1, 2, 3]]]);
- zipObj = {
- inputs: [[1, 2, 3], ['a', 'b', 'c'], ['c', 'b', 'a']]
- };
+ zipObj = {inputs: [[1, 2, 3], ['a', 'b', 'c'], ['c', 'b', 'a']]};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, 'a', 'c'], [2, 'b', 'b'], [3, 'c', 'a']]);
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B"]],
- defaults: ["C", "D"],
- useLongestLength: true
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B"]], defaults: ["C", "D"], useLongestLength: true};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
assert.eq(output[0].zipped, [[1, "A"], [2, "B"], [3, "D"]]);
- zipObj = {
- inputs: [[1, 2, 3], ["A", "B"]],
- useLongestLength: true
- };
+ zipObj = {inputs: [[1, 2, 3], ["A", "B"]], useLongestLength: true};
res = coll.aggregate([{$project: {zipped: {$zip: zipObj}}}]);
output = res.toArray();
assert.eq(1, output.length);
diff --git a/jstests/aggregation/bugs/server20169.js b/jstests/aggregation/bugs/server20169.js
index f4d8735701e..27995b8030c 100644
--- a/jstests/aggregation/bugs/server20169.js
+++ b/jstests/aggregation/bugs/server20169.js
@@ -13,49 +13,49 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
var rangeObj = [1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
28667,
"range requires two" + " or three arguments");
rangeObj = ["a", 1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34443,
"range requires a" + " numeric starting value");
rangeObj = [1.1, 1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34444,
"range requires an" + " integral starting value");
rangeObj = [1, "a"];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34445,
"range requires a" + " numeric ending value");
rangeObj = [1, 1.1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34446,
"range requires an" + " integral ending value");
rangeObj = [1, 3, "a"];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34447,
"range requires a" + " numeric step value");
rangeObj = [1, 3, 1.1];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34448,
"range requires an" + " integral step value");
rangeObj = [1, 3, 0];
assertErrorCode(coll,
- [{$project: {range: {$range: rangeObj}}}],
+ [{$project: {range: {$range: rangeObj}}}],
34449,
"range requires a" + " non-zero step value");
}());
diff --git a/jstests/aggregation/bugs/server21632.js b/jstests/aggregation/bugs/server21632.js
index 5aa9a315b5f..c99834c6f73 100644
--- a/jstests/aggregation/bugs/server21632.js
+++ b/jstests/aggregation/bugs/server21632.js
@@ -35,10 +35,7 @@
// If there is only one document, we should get that document.
var paddingStr = "abcdefghijklmnopqrstuvwxyz";
- var firstDoc = {
- _id: 0,
- paddingStr: paddingStr
- };
+ var firstDoc = {_id: 0, paddingStr: paddingStr};
assert.writeOK(coll.insert(firstDoc));
assert.eq([firstDoc], coll.aggregate([{$sample: {size: 1}}]).toArray());
assert.eq([firstDoc], coll.aggregate([{$sample: {size: 10}}]).toArray());
diff --git a/jstests/aggregation/bugs/server22093.js b/jstests/aggregation/bugs/server22093.js
index aca39a4e789..61302bbf4cd 100644
--- a/jstests/aggregation/bugs/server22093.js
+++ b/jstests/aggregation/bugs/server22093.js
@@ -22,9 +22,8 @@ load('jstests/libs/analyze_plan.js');
assert.eq(simpleGroup.length, 1);
assert.eq(simpleGroup[0]["count"], 15);
- var explained =
- coll.explain()
- .aggregate([{$match: {foo: {$gt: 0}}}, {$group: {_id: null, count: {$sum: 1}}}]);
+ var explained = coll.explain().aggregate(
+ [{$match: {foo: {$gt: 0}}}, {$group: {_id: null, count: {$sum: 1}}}]);
assert(planHasStage(explained.stages[0].$cursor.queryPlanner.winningPlan, "COUNT_SCAN"));
diff --git a/jstests/aggregation/bugs/server22580.js b/jstests/aggregation/bugs/server22580.js
index afbfdd00dcd..3a448173875 100644
--- a/jstests/aggregation/bugs/server22580.js
+++ b/jstests/aggregation/bugs/server22580.js
@@ -12,32 +12,32 @@ load("jstests/aggregation/extras/utils.js"); // For assertErrorCode.
coll.insert({});
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 0, "a"]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 0, "a"]}}}],
34452,
"$substrCP" + " does not accept non-numeric types as a length.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 0, NaN]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 0, NaN]}}}],
34453,
"$substrCP" + " does not accept non-integers as a length.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", "abc", 3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", "abc", 3]}}}],
34450,
"$substrCP does not accept non-numeric types as a starting index.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 2.2, 3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 2.2, 3]}}}],
34451,
"$substrCP" + " does not accept non-integers as a starting index.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", -1, 3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", -1, 3]}}}],
34455,
"$substrCP " + "does not accept negative integers as inputs.");
assertErrorCode(coll,
- [{$project: {substr: {$substrCP: ["abc", 1, -3]}}}],
+ [{$project: {substr: {$substrCP: ["abc", 1, -3]}}}],
34454,
"$substrCP " + "does not accept negative integers as inputs.");
}());
diff --git a/jstests/aggregation/bugs/server3253.js b/jstests/aggregation/bugs/server3253.js
index 1adab9ca977..774712ecb2f 100644
--- a/jstests/aggregation/bugs/server3253.js
+++ b/jstests/aggregation/bugs/server3253.js
@@ -58,7 +58,7 @@ assert.eq([], listCollections(/tmp\.agg_out/));
// basic test
test(input,
- [{$project: {a: {$add: ['$_id', '$_id']}}}],
+ [{$project: {a: {$add: ['$_id', '$_id']}}}],
[{_id: 1, a: 2}, {_id: 2, a: 4}, {_id: 3, a: 6}]);
// test with indexes
@@ -66,7 +66,7 @@ assert.eq(output.getIndexes().length, 1);
output.ensureIndex({a: 1});
assert.eq(output.getIndexes().length, 2);
test(input,
- [{$project: {a: {$multiply: ['$_id', '$_id']}}}],
+ [{$project: {a: {$multiply: ['$_id', '$_id']}}}],
[{_id: 1, a: 1}, {_id: 2, a: 4}, {_id: 3, a: 9}]);
// test with empty result set and make sure old result is gone, but indexes remain
@@ -81,13 +81,11 @@ test(input, [{$project: {b: "$_id"}}], [{_id: 1, b: 1}, {_id: 2, b: 2}, {_id: 3,
// test with full text index
output.ensureIndex({c: "text"});
assert.eq(output.getIndexes().length, 4);
-test(input,
- [{$project: {c: {$concat: ["hello there ", "_id"]}}}],
- [
- {_id: 1, c: "hello there _id"},
- {_id: 2, c: "hello there _id"},
- {_id: 3, c: "hello there _id"}
- ]);
+test(input, [{$project: {c: {$concat: ["hello there ", "_id"]}}}], [
+ {_id: 1, c: "hello there _id"},
+ {_id: 2, c: "hello there _id"},
+ {_id: 3, c: "hello there _id"}
+]);
// test with capped collection
cappedOutput.drop();
diff --git a/jstests/aggregation/bugs/server4588.js b/jstests/aggregation/bugs/server4588.js
index ba49c78e9ea..49f41283f6d 100644
--- a/jstests/aggregation/bugs/server4588.js
+++ b/jstests/aggregation/bugs/server4588.js
@@ -13,7 +13,12 @@
// Without includeArrayIndex.
var actualResults = coll.aggregate([{$unwind: {path: "$x"}}]).toArray();
- var expectedResults = [{_id: 3, x: 1}, {_id: 3, x: 2}, {_id: 3, x: 3}, {_id: 4, x: 5}, ];
+ var expectedResults = [
+ {_id: 3, x: 1},
+ {_id: 3, x: 2},
+ {_id: 3, x: 3},
+ {_id: 4, x: 5},
+ ];
assert.eq(expectedResults, actualResults, "Incorrect results for normal $unwind");
// With includeArrayIndex, index inserted into a new field.
@@ -28,9 +33,12 @@
// With both includeArrayIndex and preserveNullAndEmptyArrays.
// TODO: update this test when SERVER-20168 is resolved.
- actualResults = coll.aggregate([{
- $unwind: {path: "$x", includeArrayIndex: "index", preserveNullAndEmptyArrays: true}
- }]).toArray();
+ actualResults =
+ coll.aggregate([{
+ $unwind:
+ {path: "$x", includeArrayIndex: "index", preserveNullAndEmptyArrays: true}
+ }])
+ .toArray();
expectedResults = [
{_id: 0, index: null},
{_id: 1, x: null, index: null},
diff --git a/jstests/aggregation/bugs/server5044.js b/jstests/aggregation/bugs/server5044.js
index 945f31c302c..f1f77a1991d 100644
--- a/jstests/aggregation/bugs/server5044.js
+++ b/jstests/aggregation/bugs/server5044.js
@@ -10,12 +10,12 @@ function test(data, popExpected, sampExpected) {
assert.writeOK(t.insert({num: data[i]}));
var res = t.aggregate({
- $group: {
- _id: 1,
- pop: {$stdDevPop: '$num'},
- samp: {$stdDevSamp: '$num'},
- }
- }).next();
+ $group: {
+ _id: 1,
+ pop: {$stdDevPop: '$num'},
+ samp: {$stdDevSamp: '$num'},
+ }
+ }).next();
if (popExpected === null) {
assert.isnull(res.pop);
diff --git a/jstests/aggregation/bugs/server6121.js b/jstests/aggregation/bugs/server6121.js
index 97d5a4d72c9..b7ea33abdaa 100644
--- a/jstests/aggregation/bugs/server6121.js
+++ b/jstests/aggregation/bugs/server6121.js
@@ -22,20 +22,22 @@ db.s6121.drop();
db.s6121.save({date: new Timestamp(1341337661, 1)});
db.s6121.save({date: new Date(1341337661000)});
// Aggregate checking various combinations of the constant and the field
-var s6121 = db.s6121.aggregate({
- $project: {
- _id: 0,
- dayOfMonth: {$dayOfMonth: '$date'},
- dayOfWeek: {$dayOfWeek: '$date'},
- dayOfYear: {$dayOfYear: '$date'},
- hour: {$hour: '$date'},
- minute: {$minute: '$date'},
- month: {$month: '$date'},
- second: {$second: '$date'},
- week: {$week: '$date'},
- year: {$year: '$date'}
- }
-}).toArray();
+var s6121 = db.s6121
+ .aggregate({
+ $project: {
+ _id: 0,
+ dayOfMonth: {$dayOfMonth: '$date'},
+ dayOfWeek: {$dayOfWeek: '$date'},
+ dayOfYear: {$dayOfYear: '$date'},
+ hour: {$hour: '$date'},
+ minute: {$minute: '$date'},
+ month: {$month: '$date'},
+ second: {$second: '$date'},
+ week: {$week: '$date'},
+ year: {$year: '$date'}
+ }
+ })
+ .toArray();
// Assert the two entries are equal
assert.eq(s6121[0], s6121[1], 's6121 failed');
diff --git a/jstests/aggregation/bugs/server6125.js b/jstests/aggregation/bugs/server6125.js
index 746c191d8fe..bfc4f471318 100644
--- a/jstests/aggregation/bugs/server6125.js
+++ b/jstests/aggregation/bugs/server6125.js
@@ -10,9 +10,7 @@
// to make results array nested (problem 2)
function nestArray(nstArray) {
for (x = 0; x < nstArray.length; x++) {
- nstArray[x].a = {
- b: nstArray[x].a
- };
+ nstArray[x].a = {b: nstArray[x].a};
}
}
diff --git a/jstests/aggregation/bugs/server6131.js b/jstests/aggregation/bugs/server6131.js
index 602894ab721..640eea2723e 100644
--- a/jstests/aggregation/bugs/server6131.js
+++ b/jstests/aggregation/bugs/server6131.js
@@ -11,11 +11,7 @@ t.drop();
// An empty array document is dropped.
t.save({_id: 0, a: 1, b: [], c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b'
- });
+assertAggregationResults([], {$unwind: '$b'});
// Values from a nonempty array in another document are unwound.
t.save({_id: 1, b: [4, 5]});
@@ -29,48 +25,28 @@ t.drop();
// A nested empty array document is dropped.
t.save({_id: 0, a: 1, b: {x: 10, y: [], z: 20}, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b.y'
- });
+assertAggregationResults([], {$unwind: '$b.y'});
t.drop();
// A null value document is dropped.
t.save({_id: 0, a: 1, b: null, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b'
- });
+assertAggregationResults([], {$unwind: '$b'});
t.drop();
// A missing value causes the document to be dropped.
t.save({_id: 0, a: 1, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b'
- });
+assertAggregationResults([], {$unwind: '$b'});
t.drop();
// A missing value in an existing nested object causes the document to be dropped.
t.save({_id: 0, a: 1, b: {d: 4}, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b.y'
- });
+assertAggregationResults([], {$unwind: '$b.y'});
t.drop();
// A missing value in a missing nested object causes the document to be dropped.
t.save({_id: 0, a: 1, b: 10, c: 2});
-assertAggregationResults([],
- {
-$unwind:
- '$b.y'
- });
+assertAggregationResults([], {$unwind: '$b.y'});
diff --git a/jstests/aggregation/bugs/server6179.js b/jstests/aggregation/bugs/server6179.js
index 20158af7fb7..c05103a13b8 100644
--- a/jstests/aggregation/bugs/server6179.js
+++ b/jstests/aggregation/bugs/server6179.js
@@ -28,9 +28,11 @@
{movechunk: "test.data", find: {_id: 50}, to: s.getOther(s.getPrimaryShard("test")).name});
// Check that we get results rather than an error
- var result = d.data.aggregate({$group: {_id: '$_id', i: {$first: '$i'}}},
- {$group: {_id: '$i', avg_id: {$avg: '$_id'}}},
- {$sort: {_id: 1}}).toArray();
+ var result = d.data
+ .aggregate({$group: {_id: '$_id', i: {$first: '$i'}}},
+ {$group: {_id: '$i', avg_id: {$avg: '$_id'}}},
+ {$sort: {_id: 1}})
+ .toArray();
expected = [
{"_id": 0, "avg_id": 45},
{"_id": 1, "avg_id": 46},
diff --git a/jstests/aggregation/bugs/server6189.js b/jstests/aggregation/bugs/server6189.js
index 4cb615f0659..f8cb88194e2 100644
--- a/jstests/aggregation/bugs/server6189.js
+++ b/jstests/aggregation/bugs/server6189.js
@@ -11,36 +11,35 @@ function test(date, testSynthetics) {
: 'ISODate("%Y-%m-%dT%H:%M:%S.%LZ")';
// Can't use aggregate helper or assertErrorCode because we need to handle multiple error types
- var res = c.runCommand('aggregate',
- {
- pipeline: [{
- $project: {
- _id: 0,
- year: {$year: '$date'},
- month: {$month: '$date'},
- dayOfMonth: {$dayOfMonth: '$date'},
- hour: {$hour: '$date'},
- minute: {$minute: '$date'},
- second: {$second: '$date'}
-
- // server-6666
- ,
- millisecond: {$millisecond: '$date'}
-
- // server-9289
- ,
- millisecondPlusTen: {$millisecond: {$add: ['$date', 10]}}
-
- // $substr will call coerceToString
- ,
- string: {$substr: ['$date', 0, 1000]}
-
- // server-11118
- ,
- format: {$dateToString: {format: ISOfmt, date: '$date'}}
- }
- }]
- });
+ var res = c.runCommand('aggregate', {
+ pipeline: [{
+ $project: {
+ _id: 0,
+ year: {$year: '$date'},
+ month: {$month: '$date'},
+ dayOfMonth: {$dayOfMonth: '$date'},
+ hour: {$hour: '$date'},
+ minute: {$minute: '$date'},
+ second: {$second: '$date'}
+
+ // server-6666
+ ,
+ millisecond: {$millisecond: '$date'}
+
+ // server-9289
+ ,
+ millisecondPlusTen: {$millisecond: {$add: ['$date', 10]}}
+
+ // $substr will call coerceToString
+ ,
+ string: {$substr: ['$date', 0, 1000]}
+
+ // server-11118
+ ,
+ format: {$dateToString: {format: ISOfmt, date: '$date'}}
+ }
+ }]
+ });
if (date.valueOf() < 0 && _isWindows() && res.code == 16422) {
// some versions of windows (but not all) fail with dates before 1970
@@ -55,20 +54,19 @@ function test(date, testSynthetics) {
}
assert.commandWorked(res);
- assert.eq(res.result[0],
- {
- year: date.getUTCFullYear(),
- month: date.getUTCMonth() + 1 // jan == 1
- ,
- dayOfMonth: date.getUTCDate(),
- hour: date.getUTCHours(),
- minute: date.getUTCMinutes(),
- second: date.getUTCSeconds(),
- millisecond: date.getUTCMilliseconds(),
- millisecondPlusTen: ((date.getUTCMilliseconds() + 10) % 1000),
- string: date.tojson().slice(9, 28),
- format: date.tojson()
- });
+ assert.eq(res.result[0], {
+ year: date.getUTCFullYear(),
+ month: date.getUTCMonth() + 1 // jan == 1
+ ,
+ dayOfMonth: date.getUTCDate(),
+ hour: date.getUTCHours(),
+ minute: date.getUTCMinutes(),
+ second: date.getUTCSeconds(),
+ millisecond: date.getUTCMilliseconds(),
+ millisecondPlusTen: ((date.getUTCMilliseconds() + 10) % 1000),
+ string: date.tojson().slice(9, 28),
+ format: date.tojson()
+ });
if (testSynthetics) {
// Tests with this set all have the same value for these fields
diff --git a/jstests/aggregation/bugs/server6190.js b/jstests/aggregation/bugs/server6190.js
index d32a652e74b..ea7bfe1601b 100644
--- a/jstests/aggregation/bugs/server6190.js
+++ b/jstests/aggregation/bugs/server6190.js
@@ -8,8 +8,9 @@ t.drop();
t.save({});
function week(date) {
- return t.aggregate({$project: {a: {$week: date}}},
- {$match: {a: {$type: 16 /* Int type expected */}}})
+ return t
+ .aggregate({$project: {a: {$week: date}}},
+ {$match: {a: {$type: 16 /* Int type expected */}}})
.toArray()[0]
.a;
}
diff --git a/jstests/aggregation/bugs/server6195.js b/jstests/aggregation/bugs/server6195.js
index cca80a14ad5..13dccd10877 100644
--- a/jstests/aggregation/bugs/server6195.js
+++ b/jstests/aggregation/bugs/server6195.js
@@ -27,7 +27,7 @@ assertErrorCode(c, {$project: {str: {$concat: [1]}}}, 16702);
assertErrorCode(c, {$project: {str: {$concat: [NumberInt(1)]}}}, 16702);
assertErrorCode(c, {$project: {str: {$concat: [NumberLong(1)]}}}, 16702);
assertErrorCode(c, {$project: {str: {$concat: [true]}}}, 16702);
-assertErrorCode(c, {$project: {str: {$concat: [function(){}]}}}, 16702);
+assertErrorCode(c, {$project: {str: {$concat: [function() {}]}}}, 16702);
assertErrorCode(c, {$project: {str: {$concat: [{}]}}}, 16702);
assertErrorCode(c, {$project: {str: {$concat: [[]]}}}, 16702);
assertErrorCode(c, {$project: {str: {$concat: [new Timestamp(0, 0)]}}}, 16702);
diff --git a/jstests/aggregation/bugs/server6529.js b/jstests/aggregation/bugs/server6529.js
index 1bc4119c547..94af2f1fc72 100644
--- a/jstests/aggregation/bugs/server6529.js
+++ b/jstests/aggregation/bugs/server6529.js
@@ -13,16 +13,16 @@ assertErrorCode(c, {$group: {_id: {a: 1}}}, 17390);
// but any amount of nesting in a project should work
assert.eq(c.aggregate({$project: {_id: 0, a: {b: {c: {d: {e: {f: {g: 1}}}}}}}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
assert.eq(c.aggregate({$project: {_id: 0, a: {b: {c: {d: {e: {f: 1}}}}}}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
assert.eq(c.aggregate({$project: {_id: 0, a: {b: {c: {d: {e: 1}}}}}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
assert.eq(c.aggregate({$project: {_id: 0, a: {b: {c: {d: 1}}}}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
assert.eq(c.aggregate({$project: {_id: 0, a: {b: {c: 1}}}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
assert.eq(c.aggregate({$project: {_id: 0, a: {b: 1}}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
assert.eq(c.aggregate({$project: {_id: 0, a: 1}}).toArray(),
- [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
+ [{a: {b: {c: {d: {e: {f: {g: 19}}}}}}}]);
diff --git a/jstests/aggregation/bugs/server6531.js b/jstests/aggregation/bugs/server6531.js
index 7d117ce6905..7d020d79219 100644
--- a/jstests/aggregation/bugs/server6531.js
+++ b/jstests/aggregation/bugs/server6531.js
@@ -10,12 +10,8 @@ for (var x = 0; x < 10; x++) {
}
function test(variant) {
- query = {
- loc: {$within: {$center: [[5, 5], 3]}}
- };
- sort = {
- _id: 1
- };
+ query = {loc: {$within: {$center: [[5, 5], 3]}}};
+ sort = {_id: 1};
aggOut = c.aggregate({$match: query}, {$sort: sort});
cursor = c.find(query).sort(sort);
diff --git a/jstests/aggregation/bugs/server6556.js b/jstests/aggregation/bugs/server6556.js
index 636bef6b02c..261dc5a35b5 100644
--- a/jstests/aggregation/bugs/server6556.js
+++ b/jstests/aggregation/bugs/server6556.js
@@ -7,17 +7,17 @@ c.save({foo: "as\0df"});
// compare the whole string, they should match
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq: ["as\0df", "$foo"]}}}).toArray(),
- [{matches: true}]);
+ [{matches: true}]);
// compare with the substring containing only the up to the null, they should not match
assert.eq(c.aggregate({
- $project: {_id: 0, matches: {$eq: ["as\0df", {$substrBytes: ["$foo", 0, 3]}]}}
-}).toArray(),
- [{matches: false}]);
+ $project: {_id: 0, matches: {$eq: ["as\0df", {$substrBytes: ["$foo", 0, 3]}]}}
+ }).toArray(),
+ [{matches: false}]);
// partial the other way shouldnt work either
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq: ["as", "$foo"]}}}).toArray(),
- [{matches: false}]);
+ [{matches: false}]);
// neither should one that differs after the null
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq: ["as\0de", "$foo"]}}}).toArray(),
- [{matches: false}]);
+ [{matches: false}]);
// should assert on fieldpaths with a null
assert.throws(c.aggregate, {$project: {_id: 0, matches: {$eq: ["as\0df", "$f\0oo"]}}});
diff --git a/jstests/aggregation/bugs/server7781.js b/jstests/aggregation/bugs/server7781.js
index 230a8a64c9f..0a4831fb800 100644
--- a/jstests/aggregation/bugs/server7781.js
+++ b/jstests/aggregation/bugs/server7781.js
@@ -30,10 +30,7 @@
for (var i = 0; i < cmdOut.length; i++) {
massaged = {};
Object.extend(massaged, cmdOut[i].obj, /*deep=*/true);
- massaged.stats = {
- 'dis': cmdOut[i].dis,
- 'loc': cmdOut[i].loc
- };
+ massaged.stats = {'dis': cmdOut[i].dis, 'loc': cmdOut[i].loc};
if (!friendlyEqual(massaged, aggOut[i])) {
allSame = false; // don't bail yet since we want to print all differences
@@ -87,12 +84,7 @@
// test with defaults
var queryPoint = pointMaker.mkPt(0.25); // stick to center of map
- geoCmd = {
- geoNear: coll,
- near: queryPoint,
- includeLocs: true,
- spherical: true
- };
+ geoCmd = {geoNear: coll, near: queryPoint, includeLocs: true, spherical: true};
aggCmd = {
$geoNear: {
near: queryPoint,
diff --git a/jstests/aggregation/bugs/server9840.js b/jstests/aggregation/bugs/server9840.js
index b3a73cfc3d7..4316730370a 100644
--- a/jstests/aggregation/bugs/server9840.js
+++ b/jstests/aggregation/bugs/server9840.js
@@ -27,62 +27,57 @@ test({$add: ['$two', '$$CURRENT.three']}, 5);
test({$add: ['$$CURRENT.two', '$$ROOT.nested.four']}, 6);
// $let simple
-test({$let: {vars: {a: 10}, in: '$$a'}}, 10);
-test({$let: {vars: {a: '$zero'}, in: '$$a'}}, 0);
-test({$let: {vars: {a: {$add: ['$one', '$two']}, b: 10}, in: {$multiply: ['$$a', '$$b']}}}, 30);
+test({$let: {vars: {a: 10}, in : '$$a'}}, 10);
+test({$let: {vars: {a: '$zero'}, in : '$$a'}}, 0);
+test({$let: {vars: {a: {$add: ['$one', '$two']}, b: 10}, in : {$multiply: ['$$a', '$$b']}}}, 30);
// $let changing CURRENT
-test({$let: {vars: {CURRENT: '$$ROOT.nested'}, in: {$multiply: ['$four', '$$ROOT.two']}}}, 8);
-test(
- {
- $let: {
- vars: {CURRENT: '$$CURRENT.nested'}, // using original value of CURRENT
- in: {$multiply: ['$four', '$$ROOT.two']}
- }
- },
- 8);
-test(
- {
- $let: {
- vars: {CURRENT: '$nested'}, // same as last
- in: {$multiply: ['$four', '$$ROOT.two']}
- }
- },
- 8);
-test(
- {
- $let: {
- vars: {CURRENT: {$const: {ten: 10}}}, // "artificial" object
- in: {$multiply: ['$ten', '$$ROOT.two']}
- }
- },
- 20);
-test(
- {
- $let: {
- vars: {CURRENT: '$three'}, // sets current to the number 3 (not an object)
- in: {$multiply: ['$$CURRENT', '$$ROOT.two']}
- }
- },
- 6);
+test({$let: {vars: {CURRENT: '$$ROOT.nested'}, in : {$multiply: ['$four', '$$ROOT.two']}}}, 8);
+test({
+ $let: {
+ vars: {CURRENT: '$$CURRENT.nested'}, // using original value of CURRENT
+ in : {$multiply: ['$four', '$$ROOT.two']}
+ }
+},
+ 8);
+test({
+ $let: {
+ vars: {CURRENT: '$nested'}, // same as last
+ in : {$multiply: ['$four', '$$ROOT.two']}
+ }
+},
+ 8);
+test({
+ $let: {
+ vars: {CURRENT: {$const: {ten: 10}}}, // "artificial" object
+ in : {$multiply: ['$ten', '$$ROOT.two']}
+ }
+},
+ 20);
+test({
+ $let: {
+ vars: {CURRENT: '$three'}, // sets current to the number 3 (not an object)
+ in : {$multiply: ['$$CURRENT', '$$ROOT.two']}
+ }
+},
+ 6);
// swapping with $let (ensures there is no ordering dependency in vars)
-test(
- {
- $let: {
- vars: {x: 6, y: 10},
- in: {
- $let: {
- vars: {x: '$$y', y: '$$x'}, // now {x:10, y:6}
- in: {$subtract: ['$$x', '$$y']}
- }
- }
- }
- }, // not commutative!
- 4); // 10-6 not 6-10 or 6-6
+test({
+ $let: {
+ vars: {x: 6, y: 10},
+ in : {
+ $let: {
+ vars: {x: '$$y', y: '$$x'}, // now {x:10, y:6}
+ in : {$subtract: ['$$x', '$$y']}
+ }
+ }
+ }
+}, // not commutative!
+ 4); // 10-6 not 6-10 or 6-6
// unicode is allowed
-test({$let: {vars: {'日本語': 10}, in: '$$日本語'}}, 10); // Japanese for "Japanese language"
+test({$let: {vars: {'日本語': 10}, in : '$$日本語'}}, 10); // Japanese for "Japanese language"
// Can use ROOT and CURRENT directly with no subfield (SERVER-5916)
t.drop();
@@ -90,15 +85,15 @@ t.insert({_id: 'obj'});
assert.eq(t.aggregate({$project: {_id: 0, obj: '$$ROOT'}}).toArray(), [{obj: {_id: 'obj'}}]);
assert.eq(t.aggregate({$project: {_id: 0, obj: '$$CURRENT'}}).toArray(), [{obj: {_id: 'obj'}}]);
assert.eq(t.aggregate({$group: {_id: 0, objs: {$push: '$$ROOT'}}}).toArray(),
- [{_id: 0, objs: [{_id: 'obj'}]}]);
+ [{_id: 0, objs: [{_id: 'obj'}]}]);
assert.eq(t.aggregate({$group: {_id: 0, objs: {$push: '$$CURRENT'}}}).toArray(),
- [{_id: 0, objs: [{_id: 'obj'}]}]);
+ [{_id: 0, objs: [{_id: 'obj'}]}]);
// check name validity checks
-assertErrorCode(t, {$project: {a: {$let: {vars: {ROOT: 1}, in: '$$ROOT'}}}}, 16867);
-assertErrorCode(t, {$project: {a: {$let: {vars: {FOO: 1}, in: '$$FOO'}}}}, 16867);
-assertErrorCode(t, {$project: {a: {$let: {vars: {_underbar: 1}, in: '$$FOO'}}}}, 16867);
-assertErrorCode(t, {$project: {a: {$let: {vars: {'a.b': 1}, in: '$$FOO'}}}}, 16868);
-assertErrorCode(t, {$project: {a: {$let: {vars: {'a b': 1}, in: '$$FOO'}}}}, 16868);
+assertErrorCode(t, {$project: {a: {$let: {vars: {ROOT: 1}, in : '$$ROOT'}}}}, 16867);
+assertErrorCode(t, {$project: {a: {$let: {vars: {FOO: 1}, in : '$$FOO'}}}}, 16867);
+assertErrorCode(t, {$project: {a: {$let: {vars: {_underbar: 1}, in : '$$FOO'}}}}, 16867);
+assertErrorCode(t, {$project: {a: {$let: {vars: {'a.b': 1}, in : '$$FOO'}}}}, 16868);
+assertErrorCode(t, {$project: {a: {$let: {vars: {'a b': 1}, in : '$$FOO'}}}}, 16868);
assertErrorCode(t, {$project: {a: '$$_underbar'}}, 16870);
assertErrorCode(t, {$project: {a: '$$with spaces'}}, 16871);
diff --git a/jstests/aggregation/bugs/server9841.js b/jstests/aggregation/bugs/server9841.js
index 5bf9b32db93..28e6037caf1 100644
--- a/jstests/aggregation/bugs/server9841.js
+++ b/jstests/aggregation/bugs/server9841.js
@@ -16,27 +16,26 @@ function test(expression, expected) {
assert.eq(result, [{res: expected}]);
}
-test({$map: {input: "$simple", as: "var", in: '$$var'}}, [1, 2, 3, 4]);
-test({$map: {input: "$simple", as: "var", in: {$add: [10, '$$var']}}}, [11, 12, 13, 14]);
+test({$map: {input: "$simple", as: "var", in : '$$var'}}, [1, 2, 3, 4]);
+test({$map: {input: "$simple", as: "var", in : {$add: [10, '$$var']}}}, [11, 12, 13, 14]);
-test({$map: {input: "$nested", as: "var", in: '$$var.a'}}, [1, 2]);
-test({$map: {input: "$nested", as: "CURRENT", in: '$a'}}, [1, 2]);
+test({$map: {input: "$nested", as: "var", in : '$$var.a'}}, [1, 2]);
+test({$map: {input: "$nested", as: "CURRENT", in : '$a'}}, [1, 2]);
-test({$map: {input: "$mixed", as: "var", in: '$$var.a'}},
+test({$map: {input: "$mixed", as: "var", in : '$$var.a'}},
[1, null, 2, null]); // missing becomes null
-test({$map: {input: "$null", as: "var", in: '$$var'}}, null);
+test({$map: {input: "$null", as: "var", in : '$$var'}}, null);
// can't set ROOT
-assertErrorCode(t, {$project: {a: {$map: {input: "$simple", as: "ROOT", in: '$$ROOT'}}}}, 16867);
+assertErrorCode(t, {$project: {a: {$map: {input: "$simple", as: "ROOT", in : '$$ROOT'}}}}, 16867);
// error on non-array
-assertErrorCode(t, {$project: {a: {$map: {input: "$notArray", as: "var", in: '$$var'}}}}, 16883);
+assertErrorCode(t, {$project: {a: {$map: {input: "$notArray", as: "var", in : '$$var'}}}}, 16883);
// parse errors (missing or extra fields)
-assertErrorCode(t,
- {$project: {a: {$map: {x: 1, input: "$simple", as: "var", in: '$$var'}}}},
- 16879);
-assertErrorCode(t, {$project: {a: {$map: {as: "var", in: '$$var'}}}}, 16880);
-assertErrorCode(t, {$project: {a: {$map: {input: "$simple", in: '$$var'}}}}, 16881);
+assertErrorCode(
+ t, {$project: {a: {$map: {x: 1, input: "$simple", as: "var", in : '$$var'}}}}, 16879);
+assertErrorCode(t, {$project: {a: {$map: {as: "var", in : '$$var'}}}}, 16880);
+assertErrorCode(t, {$project: {a: {$map: {input: "$simple", in : '$$var'}}}}, 16881);
assertErrorCode(t, {$project: {a: {$map: {input: "$simple", as: "var"}}}}, 16882);
diff --git a/jstests/aggregation/bugs/substr.js b/jstests/aggregation/bugs/substr.js
index 9b514eb4679..8581aaf5601 100644
--- a/jstests/aggregation/bugs/substr.js
+++ b/jstests/aggregation/bugs/substr.js
@@ -108,18 +108,18 @@ assertSubstring('cde', '$z', {$add: ['$b', 1]}, {$add: [2, '$d']});
assert.eq(
'e',
t.aggregate({
- $project: {
- a: {
- $substrBytes: [
- {
- $substrBytes:
- [{$substrBytes: [{$substrBytes: ['abcdefghij', 1, 6]}, 2, 5]}, 0, 3]
- },
- 1,
- 1
- ]
- }
- }
- })
+ $project: {
+ a: {
+ $substrBytes: [
+ {
+ $substrBytes:
+ [{$substrBytes: [{$substrBytes: ['abcdefghij', 1, 6]}, 2, 5]}, 0, 3]
+ },
+ 1,
+ 1
+ ]
+ }
+ }
+ })
.toArray()[0]
.a);
diff --git a/jstests/aggregation/bugs/upperlower.js b/jstests/aggregation/bugs/upperlower.js
index 60bcba8db20..a393bf3bd72 100644
--- a/jstests/aggregation/bugs/upperlower.js
+++ b/jstests/aggregation/bugs/upperlower.js
@@ -6,8 +6,9 @@ t.drop();
t.save({});
function assertResult(expectedUpper, expectedLower, string) {
- result = t.aggregate({$project: {upper: {$toUpper: string}, lower: {$toLower: string}}})
- .toArray()[0];
+ result = t.aggregate({
+ $project: {upper: {$toUpper: string}, lower: {$toLower: string}}
+ }).toArray()[0];
assert.eq(expectedUpper, result.upper);
assert.eq(expectedLower, result.lower);
}