diff options
Diffstat (limited to 'jstests/core')
197 files changed, 1495 insertions, 2137 deletions
diff --git a/jstests/core/apitest_db.js b/jstests/core/apitest_db.js index 2713a6cfd24..be90b9eb877 100644 --- a/jstests/core/apitest_db.js +++ b/jstests/core/apitest_db.js @@ -73,9 +73,9 @@ assert.docEq(validStorageEngineOptions, // The indexOptionDefaults must be a document that contains only a storageEngine field. db.idxOptions.drop(); assert.commandFailed(db.createCollection('idxOptions', {indexOptionDefaults: 'not a document'})); -assert.commandFailed(db.createCollection('idxOptions', - {indexOptionDefaults: {unknownOption: true}}), - 'created a collection with an unknown option to indexOptionDefaults'); +assert.commandFailed( + db.createCollection('idxOptions', {indexOptionDefaults: {unknownOption: true}}), + 'created a collection with an unknown option to indexOptionDefaults'); assert.commandWorked(db.createCollection('idxOptions', {indexOptionDefaults: {}}), 'should have been able to specify an empty object for indexOptionDefaults'); assert(db.idxOptions.drop()); @@ -99,9 +99,7 @@ assert.commandFailed( var alternateStorageEngine = db.serverBuildInfo().storageEngines.find(engine => engine !== storageEngineName); if (alternateStorageEngine) { - var indexOptions = { - storageEngine: {[alternateStorageEngine]: {}} - }; + var indexOptions = {storageEngine: {[alternateStorageEngine]: {}}}; assert.commandWorked(db.createCollection('idxOptions', {indexOptionDefaults: indexOptions}), 'should have been able to configure a non-active storage engine'); assert(db.idxOptions.drop()); diff --git a/jstests/core/apitest_dbcollection.js b/jstests/core/apitest_dbcollection.js index 8f0129319f7..ac30128b90e 100644 --- a/jstests/core/apitest_dbcollection.js +++ b/jstests/core/apitest_dbcollection.js @@ -214,9 +214,7 @@ assert.eq(0, db.getCollection("test_db").getIndexes().length, "24"); } // indexDetailsKey - show indexDetails results for this index key only. - var indexKey = { - a: 1 - }; + var indexKey = {a: 1}; var indexName = getIndexName(indexKey); checkIndexDetails({indexDetails: true, indexDetailsKey: indexKey}, indexName); diff --git a/jstests/core/apply_ops1.js b/jstests/core/apply_ops1.js index 8a19caa9f23..96840f125e9 100644 --- a/jstests/core/apply_ops1.js +++ b/jstests/core/apply_ops1.js @@ -156,10 +156,7 @@ assert.eq(1, t.find().count(), "Duplicate insert failed"); assert.eq(true, a.results[0], "Bad result value for duplicate insert"); - var o = { - _id: 5, - x: 17 - }; + var o = {_id: 5, x: 17}; assert.eq(o, t.findOne(), "Mismatching document inserted."); var res = db.runCommand({ @@ -243,8 +240,9 @@ res = t.getIndexes(); assert.eq(1, res.filter(function(element, index, array) { - return element.name == 'a_1'; - }).length, + return element.name == 'a_1'; + }) + .length, 'Foreground index not found in listIndexes result: ' + tojson(res)); // Background indexes are created in the foreground when processed by applyOps. @@ -265,7 +263,8 @@ res = t.getIndexes(); assert.eq(1, res.filter(function(element, index, array) { - return element.name == 'b_1'; - }).length, + return element.name == 'b_1'; + }) + .length, 'Background index not found in listIndexes result: ' + tojson(res)); })(); diff --git a/jstests/core/array4.js b/jstests/core/array4.js index c6fe1599880..fe131a04ca9 100644 --- a/jstests/core/array4.js +++ b/jstests/core/array4.js @@ -5,9 +5,7 @@ t.drop(); t.insert({"a": ["1", "2", "3"]}); t.insert({"a": ["2", "1"]}); -var x = { - 'a.0': /1/ -}; +var x = {'a.0': /1/}; assert.eq(t.count(x), 1); diff --git a/jstests/core/array_match4.js b/jstests/core/array_match4.js index 4956fc1d8b2..b4cdec5143a 100644 --- a/jstests/core/array_match4.js +++ b/jstests/core/array_match4.js @@ -3,9 +3,7 @@ var t = db.array_match4; t.drop(); t.save({a: [1, 2]}); -var query_gte = { - a: {$gte: [1, 2]} -}; +var query_gte = {a: {$gte: [1, 2]}}; // // without index diff --git a/jstests/core/arrayfind7.js b/jstests/core/arrayfind7.js index f0dc2e2caa8..699f8c9586d 100644 --- a/jstests/core/arrayfind7.js +++ b/jstests/core/arrayfind7.js @@ -36,10 +36,9 @@ checkElemMatch({'a.b.c': 1}, {a: {$elemMatch: {b: {$elemMatch: {c: {$gte: 1, $in: [2]}}}}}}); // Two nested $elemMatch expressions. -checkElemMatch( - {'a.d.e': 1, 'a.b.c': 1}, - {a: [{b: [{c: 1}], d: [{e: 1}]}]}, - {a: {$elemMatch: {d: {$elemMatch: {e: {$lte: 1}}}, b: {$elemMatch: {c: {$gte: 1}}}}}}); +checkElemMatch({'a.d.e': 1, 'a.b.c': 1}, {a: [{b: [{c: 1}], d: [{e: 1}]}]}, { + a: {$elemMatch: {d: {$elemMatch: {e: {$lte: 1}}}, b: {$elemMatch: {c: {$gte: 1}}}}} +}); // A non $elemMatch expression and a nested $elemMatch expression. checkElemMatch({'a.x': 1, 'a.b.c': 1}, diff --git a/jstests/core/arrayfind8.js b/jstests/core/arrayfind8.js index d322229a298..a687351b554 100644 --- a/jstests/core/arrayfind8.js +++ b/jstests/core/arrayfind8.js @@ -77,20 +77,14 @@ function checkQuery(subQuery, bothMatch, elemMatch, nonElemMatch, additionalCons // Construct standard and elemMatch queries from subQuery. firstSubQueryKey = Object.keySet(subQuery)[0]; if (firstSubQueryKey[0] == '$') { - standardQuery = { - $and: [{a: subQuery}, additionalConstraints] - }; + standardQuery = {$and: [{a: subQuery}, additionalConstraints]}; } else { // If the subQuery contains a field rather than operators, append to the 'a' field. modifiedSubQuery = {}; modifiedSubQuery['a.' + firstSubQueryKey] = subQuery[firstSubQueryKey]; - standardQuery = { - $and: [modifiedSubQuery, additionalConstraints] - }; + standardQuery = {$and: [modifiedSubQuery, additionalConstraints]}; } - elemMatchQuery = { - $and: [{a: {$elemMatch: subQuery}}, additionalConstraints] - }; + elemMatchQuery = {$and: [{a: {$elemMatch: subQuery}}, additionalConstraints]}; debug(elemMatchQuery); function maySave(aValue) { diff --git a/jstests/core/basic3.js b/jstests/core/basic3.js index ec0b48ec0cf..2fa26627bf9 100644 --- a/jstests/core/basic3.js +++ b/jstests/core/basic3.js @@ -35,7 +35,6 @@ t.update({"a": 0}, {$set: {"c.c": 1}}); t.update({"a": 0}, {$inc: {"c.c": 1}}); // edge cases -assert.throws(doBadUpdate, - [{a: 0}, {"": {"b.b": 1}}], - "must deny '' embedded '.' in key of update"); +assert.throws( + doBadUpdate, [{a: 0}, {"": {"b.b": 1}}], "must deny '' embedded '.' in key of update"); t.update({"a": 0}, {}); diff --git a/jstests/core/basic9.js b/jstests/core/basic9.js index bebaeb54740..6d368f46e3b 100644 --- a/jstests/core/basic9.js +++ b/jstests/core/basic9.js @@ -14,6 +14,5 @@ t.save({foo$foo: 5}); t.save({foo$: 5}); assert.throws(doBadSave, [{$foo: 5}], "key names aren't allowed to start with $ doesn't work"); -assert.throws(doBadSave, - [{x: {$foo: 5}}], - "embedded key names aren't allowed to start with $ doesn't work"); +assert.throws( + doBadSave, [{x: {$foo: 5}}], "embedded key names aren't allowed to start with $ doesn't work"); diff --git a/jstests/core/batch_size.js b/jstests/core/batch_size.js index eca41e412ba..3dfbe0face6 100644 --- a/jstests/core/batch_size.js +++ b/jstests/core/batch_size.js @@ -95,12 +95,7 @@ while (bigStr.length < 1000000) { // Insert enough documents to exceed the 32 MB in-memory sort limit. for (var i = 0; i < 40; i++) { - var doc = { - x: 1, - y: 1, - z: i, - big: bigStr - }; + var doc = {x: 1, y: 1, z: i, big: bigStr}; t.insert(doc); } diff --git a/jstests/core/big_object1.js b/jstests/core/big_object1.js index 017fcdc9756..8029cbb868f 100644 --- a/jstests/core/big_object1.js +++ b/jstests/core/big_object1.js @@ -11,10 +11,7 @@ if (db.adminCommand("buildinfo").bits == 64) { x = 0; while (true) { var result; - n = { - _id: x, - a: [] - }; + n = {_id: x, a: []}; for (i = 0; i < 14 + x; i++) n.a.push(s); try { diff --git a/jstests/core/bittest.js b/jstests/core/bittest.js index 45559d8f505..0a54215ee60 100644 --- a/jstests/core/bittest.js +++ b/jstests/core/bittest.js @@ -144,14 +144,13 @@ assertQueryCorrect({a: {$bitsAnyClear: BinData(0, "////////////////////////////")}}, 3); // Tests with multiple predicates. - assertQueryCorrect( - { - a: { - $bitsAllSet: BinData(0, "AANgAAAAAAAAAAAAAAAAAAAAAAAA"), - $bitsAllClear: BinData(0, "//yf////////////////////////") - } - }, - 1); + assertQueryCorrect({ + a: { + $bitsAllSet: BinData(0, "AANgAAAAAAAAAAAAAAAAAAAAAAAA"), + $bitsAllClear: BinData(0, "//yf////////////////////////") + } + }, + 1); coll.drop(); })();
\ No newline at end of file diff --git a/jstests/core/capped6.js b/jstests/core/capped6.js index d7b8a60985a..e94e7ea44e8 100644 --- a/jstests/core/capped6.js +++ b/jstests/core/capped6.js @@ -38,9 +38,7 @@ var c = ""; for (i = 0; i < maxDocuments; ++i, c += "-") { // The a values are strings of increasing length. - valueArray[i] = { - a: c - }; + valueArray[i] = {a: c}; } if (shouldReverse) { valueArray.reverse(); diff --git a/jstests/core/collation_shell_helpers.js b/jstests/core/collation_shell_helpers.js index 99dda6047b1..e9308960164 100644 --- a/jstests/core/collation_shell_helpers.js +++ b/jstests/core/collation_shell_helpers.js @@ -47,49 +47,46 @@ db.createCollection("collation_shell_helpers", {collation: {locale: "fr_CA"}})); var collectionInfos = db.getCollectionInfos({name: "collation_shell_helpers"}); assert.eq(collectionInfos.length, 1); - assert.eq(collectionInfos[0].options.collation, - { - locale: "fr_CA", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: true - }); + assert.eq(collectionInfos[0].options.collation, { + locale: "fr_CA", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: true + }); // Ensure that an index with no collation inherits the collection-default collation. assert.commandWorked(coll.ensureIndex({a: 1})); - assertIndexHasCollation({a: 1}, - { - locale: "fr_CA", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: true - }); + assertIndexHasCollation({a: 1}, { + locale: "fr_CA", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: true + }); // Ensure that an index which specifies an overriding collation does not use the collection // default. assert.commandWorked(coll.ensureIndex({b: 1}, {collation: {locale: "en_US"}})); - assertIndexHasCollation({b: 1}, - { - locale: "en_US", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: false - }); + assertIndexHasCollation({b: 1}, { + locale: "en_US", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: false + }); coll.drop(); @@ -106,58 +103,54 @@ assert.commandFailed(coll.ensureIndex({a: 1}, {collation: {locale: "en", strength: 99}})); assert.commandWorked(coll.ensureIndex({a: 1}, {collation: {locale: "en_US"}})); - assertIndexHasCollation({a: 1}, - { - locale: "en_US", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: false - }); + assertIndexHasCollation({a: 1}, { + locale: "en_US", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: false + }); assert.commandWorked(coll.createIndex({b: 1}, {collation: {locale: "en_US"}})); - assertIndexHasCollation({b: 1}, - { - locale: "en_US", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: false - }); + assertIndexHasCollation({b: 1}, { + locale: "en_US", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: false + }); assert.commandWorked(coll.createIndexes([{c: 1}, {d: 1}], {collation: {locale: "fr_CA"}})); - assertIndexHasCollation({c: 1}, - { - locale: "fr_CA", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: true - }); - assertIndexHasCollation({d: 1}, - { - locale: "fr_CA", - caseLevel: false, - caseFirst: "off", - strength: 3, - numericOrdering: false, - alternate: "non-ignorable", - maxVariable: "punct", - normalization: false, - backwards: true - }); + assertIndexHasCollation({c: 1}, { + locale: "fr_CA", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: true + }); + assertIndexHasCollation({d: 1}, { + locale: "fr_CA", + caseLevel: false, + caseFirst: "off", + strength: 3, + numericOrdering: false, + alternate: "non-ignorable", + maxVariable: "punct", + normalization: false, + backwards: true + }); // TODO SERVER-23791: Test that queries with matching collations can use these indices, and that // the indices contain collator-generated comparison keys rather than the verbatim indexed @@ -172,21 +165,8 @@ assert.writeOK(coll.insert({_id: 2, str: "bar"})); // Aggregation. - assert.eq(2, - coll.aggregate([], - { - collation : { - locale: - "fr" - } - }).itcount()); - assert.commandWorked(coll.explain().aggregate([], - { - collation : { - locale: - "fr" - } - })); + assert.eq(2, coll.aggregate([], {collation: {locale: "fr"}}).itcount()); + assert.commandWorked(coll.explain().aggregate([], {collation: {locale: "fr"}})); // Count command. assert.eq(0, coll.find({str: "FOO"}).count()); @@ -236,28 +216,24 @@ assert.commandWorked(coll.find().collation({locale: "fr"}).explain()); // findAndModify. - assert.eq({_id: 2, str: "baz"}, - coll.findAndModify({ - query: {str: "bar"}, - update: {$set: {str: "baz"}}, new: true, - collation: {locale: "fr"} - })); - assert.commandWorked(coll.explain().findAndModify({ + assert.eq({_id: 2, str: "baz"}, coll.findAndModify({ query: {str: "bar"}, - update: {$set: {str: "baz"}}, new: true, + update: {$set: {str: "baz"}}, + new: true, collation: {locale: "fr"} })); + assert.commandWorked(coll.explain().findAndModify( + {query: {str: "bar"}, update: {$set: {str: "baz"}}, new: true, collation: {locale: "fr"}})); // Group. - assert.eq([{str: "foo", count: 1}, {str: "baz", count: 1}], - coll.group({ - key: {str: 1}, - initial: {count: 0}, - reduce: function(curr, result) { - result.count += 1; - }, - collation: {locale: "fr"} - })); + assert.eq([{str: "foo", count: 1}, {str: "baz", count: 1}], coll.group({ + key: {str: 1}, + initial: {count: 0}, + reduce: function(curr, result) { + result.count += 1; + }, + collation: {locale: "fr"} + })); assert.commandWorked(coll.explain().group({ key: {str: 1}, initial: {count: 0}, @@ -323,79 +299,95 @@ // String field not indexed. assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); assert.eq(0, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"} + })) + .results.length); assert.eq(1, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"}, - collation: {locale: "en_US", strength: 2} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"}, + collation: {locale: "en_US", strength: 2} + })) + .results.length); // String field indexed without collation. assert.commandWorked(coll.dropIndexes()); assert.commandWorked(coll.ensureIndex({geo: "2dsphere", str: 1})); assert.eq(0, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"} + })) + .results.length); assert.eq(1, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"}, - collation: {locale: "en_US", strength: 2} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"}, + collation: {locale: "en_US", strength: 2} + })) + .results.length); // String field indexed with non-matching collation. assert.commandWorked(coll.dropIndexes()); assert.commandWorked( coll.ensureIndex({geo: "2dsphere", str: 1}, {collation: {locale: "en_US", strength: 3}})); assert.eq(0, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"} + })) + .results.length); assert.eq(1, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"}, - collation: {locale: "en_US", strength: 2} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"}, + collation: {locale: "en_US", strength: 2} + })) + .results.length); // String field indexed with matching collation. assert.commandWorked(coll.dropIndexes()); assert.commandWorked( coll.ensureIndex({geo: "2dsphere", str: 1}, {collation: {locale: "en_US", strength: 2}})); assert.eq(0, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"} + })) + .results.length); assert.eq(1, - assert.commandWorked(db.runCommand({ - geoNear: coll.getName(), - near: {type: "Point", coordinates: [0, 0]}, - spherical: true, - query: {str: "ABC"}, - collation: {locale: "en_US", strength: 2} - })).results.length); + assert + .commandWorked(db.runCommand({ + geoNear: coll.getName(), + near: {type: "Point", coordinates: [0, 0]}, + spherical: true, + query: {str: "ABC"}, + collation: {locale: "en_US", strength: 2} + })) + .results.length); coll.drop(); @@ -407,14 +399,15 @@ assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); assert.eq(0, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }).itcount()); + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) + .itcount()); assert.eq(1, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }) + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) .collation({locale: "en_US", strength: 2}) .itcount()); @@ -423,14 +416,15 @@ assert.commandWorked(coll.ensureIndex({geo: "2dsphere", str: 1})); assert.eq(0, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }).itcount()); + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) + .itcount()); assert.eq(1, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }) + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) .collation({locale: "en_US", strength: 2}) .itcount()); @@ -440,14 +434,15 @@ {collation: {locale: "en_US", strength: 3}})); assert.eq(0, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }).itcount()); + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) + .itcount()); assert.eq(1, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }) + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) .collation({locale: "en_US", strength: 2}) .itcount()); @@ -457,14 +452,15 @@ {collation: {locale: "en_US", strength: 2}})); assert.eq(0, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }).itcount()); + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) + .itcount()); assert.eq(1, coll.find({ - str: "ABC", - geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} - }) + str: "ABC", + geo: {$nearSphere: {$geometry: {type: "Point", coordinates: [0, 0]}}} + }) .collation({locale: "en_US", strength: 2}) .itcount()); @@ -684,11 +680,8 @@ } else { assert.throws(function() { coll.bulkWrite([{ - replaceOne: { - filter: {str: "foo"}, - replacement: {str: "bar"}, - collation: {locale: "fr"} - } + replaceOne: + {filter: {str: "foo"}, replacement: {str: "bar"}, collation: {locale: "fr"}} }]); }); } diff --git a/jstests/core/commands_that_do_not_write_do_not_accept_wc.js b/jstests/core/commands_that_do_not_write_do_not_accept_wc.js index 3faab189bcb..ef5f8762a42 100644 --- a/jstests/core/commands_that_do_not_write_do_not_accept_wc.js +++ b/jstests/core/commands_that_do_not_write_do_not_accept_wc.js @@ -22,9 +22,7 @@ }); }, reduce: function(key, values) { - return { - count: values.length - }; + return {count: values.length}; }, out: {inline: 1} }); diff --git a/jstests/core/connection_status.js b/jstests/core/connection_status.js index 728e3d8a131..47aab3f0f43 100644 --- a/jstests/core/connection_status.js +++ b/jstests/core/connection_status.js @@ -70,14 +70,8 @@ } function test(userName) { - var user = { - user: userName, - db: dbName - }; - var role = { - role: "root", - db: "admin" - }; + var user = {user: userName, db: dbName}; + var role = {role: "root", db: "admin"}; myDB.createUser({user: userName, pwd: "weak password", roles: [role]}); myDB.auth(userName, "weak password"); diff --git a/jstests/core/constructors.js b/jstests/core/constructors.js index 814766ee2c3..34e6cbed9a6 100644 --- a/jstests/core/constructors.js +++ b/jstests/core/constructors.js @@ -12,10 +12,7 @@ function addConstructorsWithNew(constructorList) { // We use slice(0) here to make a copy of our lists var validWithNew = valid.concat(valid.slice(0).map(prependNew)); var invalidWithNew = invalid.concat(invalid.slice(0).map(prependNew)); - return { - "valid": validWithNew, - "invalid": invalidWithNew - }; + return {"valid": validWithNew, "invalid": invalidWithNew}; } function clientEvalConstructorTest(constructorList) { @@ -142,12 +139,22 @@ var dbpointerConstructors = { }; var objectidConstructors = { - "valid": ['ObjectId()', 'ObjectId("FFFFFFFFFFFFFFFFFFFFFFFF")', ], - "invalid": ['ObjectId(5)', 'ObjectId("FFFFFFFFFFFFFFFFFFFFFFFQ")', ] + "valid": [ + 'ObjectId()', + 'ObjectId("FFFFFFFFFFFFFFFFFFFFFFFF")', + ], + "invalid": [ + 'ObjectId(5)', + 'ObjectId("FFFFFFFFFFFFFFFFFFFFFFFQ")', + ] }; var timestampConstructors = { - "valid": ['Timestamp()', 'Timestamp(0,0)', 'Timestamp(1.0,1.0)', ], + "valid": [ + 'Timestamp()', + 'Timestamp(0,0)', + 'Timestamp(1.0,1.0)', + ], "invalid": [ 'Timestamp(0)', 'Timestamp(0,0,0)', @@ -161,7 +168,9 @@ var timestampConstructors = { }; var bindataConstructors = { - "valid": ['BinData(0,"test")', ], + "valid": [ + 'BinData(0,"test")', + ], "invalid": [ 'BinData(0,"test", "test")', 'BinData()', @@ -178,7 +187,9 @@ var bindataConstructors = { }; var uuidConstructors = { - "valid": ['UUID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")', ], + "valid": [ + 'UUID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")', + ], "invalid": [ 'UUID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0)', 'UUID()', @@ -195,7 +206,9 @@ var uuidConstructors = { }; var md5Constructors = { - "valid": ['MD5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")', ], + "valid": [ + 'MD5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")', + ], "invalid": [ 'MD5("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0)', 'MD5()', @@ -238,7 +251,13 @@ var hexdataConstructors = { }; var dateConstructors = { - "valid": ['Date()', 'Date(0)', 'Date(0,0)', 'Date(0,0,0)', 'Date("foo")', ], + "valid": [ + 'Date()', + 'Date(0)', + 'Date(0,0)', + 'Date(0,0,0)', + 'Date("foo")', + ], "invalid": [] }; diff --git a/jstests/core/convert_to_capped_nonexistant.js b/jstests/core/convert_to_capped_nonexistant.js index a09ce553788..08996087da7 100644 --- a/jstests/core/convert_to_capped_nonexistant.js +++ b/jstests/core/convert_to_capped_nonexistant.js @@ -7,9 +7,8 @@ testDb.dropDatabase(); // Database does not exist here var result = testDb.runCommand({convertToCapped: 'foo', size: 1024}); assert.eq(result.ok, 0, "converting a nonexistent to capped worked and should not have"); -assert.eq(result.code, - 26, - "converting a nonexistent database to capped failed, but code has changed"); +assert.eq( + result.code, 26, "converting a nonexistent database to capped failed, but code has changed"); assert.eq(result.errmsg, "database convert_to_capped_nonexistent not found", "converting a nonexistent to capped failed, but message has changed"); @@ -19,9 +18,8 @@ testDb.coll.insert({}); var result = testDb.runCommand({convertToCapped: 'foo', size: 1024}); assert.eq(result.ok, 0, "converting a nonexistent to capped worked and should not have"); -assert.eq(result.code, - 26, - "converting a nonexistent collection to capped failed, but code has changed"); +assert.eq( + result.code, 26, "converting a nonexistent collection to capped failed, but code has changed"); assert.eq(result.errmsg, "source collection convert_to_capped_nonexistent.foo does not exist", "converting a nonexistent to capped failed, but message has changed"); diff --git a/jstests/core/count11.js b/jstests/core/count11.js index 4ce218bfc43..aeda1e4b1cf 100644 --- a/jstests/core/count11.js +++ b/jstests/core/count11.js @@ -5,12 +5,8 @@ var t = db.count11; t.drop(); -var validQuery = { - a: 1 -}; -var invalidQuery = { - a: {$invalid: 1} -}; +var validQuery = {a: 1}; +var invalidQuery = {a: {$invalid: 1}}; // Query non-existing collection with empty query. assert.eq(0, t.find().count()); diff --git a/jstests/core/create_indexes.js b/jstests/core/create_indexes.js index 3e069d7478e..a6cdb99ea89 100644 --- a/jstests/core/create_indexes.js +++ b/jstests/core/create_indexes.js @@ -114,9 +114,11 @@ res = t.runCommand("createIndexes", {indexes: [{key: {"c": 1}, sparse: true, name: "c_1"}]}); assert.eq(6, t.getIndexes().length); assert.eq(1, - t.getIndexes().filter(function(z) { - return z.sparse; - }).length); + t.getIndexes() + .filter(function(z) { + return z.sparse; + }) + .length); res = t.runCommand("createIndexes", {indexes: [{key: {"x": "foo"}, name: "x_1"}]}); assert(!res.ok); diff --git a/jstests/core/crud_api.js b/jstests/core/crud_api.js index f6cc77025c3..c9dbfb40c85 100644 --- a/jstests/core/crud_api.js +++ b/jstests/core/crud_api.js @@ -32,9 +32,7 @@ if (db.getMongo().writeMode() === 'commands') { assert.docEq(first, second); } else { - var overrideModifiedCount = { - modifiedCount: undefined - }; + var overrideModifiedCount = {modifiedCount: undefined}; assert.docEq(Object.merge(first, overrideModifiedCount), Object.merge(second, overrideModifiedCount)); } diff --git a/jstests/core/currentop_predicate.js b/jstests/core/currentop_predicate.js index 98df3c9756e..73b8a006588 100644 --- a/jstests/core/currentop_predicate.js +++ b/jstests/core/currentop_predicate.js @@ -1,22 +1,20 @@ // Tests the use of a match predicate with the currentOp command. (function() { // Test a $where predicate that matches the currentOp operation we are running. - var res = db.adminCommand("currentOp", - { - $where: function() { - return true; - } - }); + var res = db.adminCommand("currentOp", { + $where: function() { + return true; + } + }); assert.commandWorked(res); assert.gt(res.inprog.length, 0, tojson(res)); // Test a $where predicate that matches no operations. - res = db.adminCommand("currentOp", - { - $where: function() { - return false; - } - }); + res = db.adminCommand("currentOp", { + $where: function() { + return false; + } + }); assert.commandWorked(res); assert.eq(res.inprog.length, 0, tojson(res)); })(); diff --git a/jstests/core/cursor5.js b/jstests/core/cursor5.js index 64158eaccec..0232b92e4cc 100644 --- a/jstests/core/cursor5.js +++ b/jstests/core/cursor5.js @@ -24,16 +24,8 @@ function testBoundsWithSubobjectIndexes(db) { ]; for (i = 0; i < z.length; ++i) r.save(z[i]); - idx = { - "a.d": 1, - a: 1, - e: -1 - }; - rIdx = { - "a.d": -1, - a: -1, - e: 1 - }; + idx = {"a.d": 1, a: 1, e: -1}; + rIdx = {"a.d": -1, a: -1, e: 1}; r.ensureIndex(idx); checkResults([z[0], z[4], z[2]], r.find({e: 4}).sort(idx).hint(idx)); diff --git a/jstests/core/cursor6.js b/jstests/core/cursor6.js index f793d37bfe5..d373e952b2d 100644 --- a/jstests/core/cursor6.js +++ b/jstests/core/cursor6.js @@ -8,14 +8,9 @@ function eq(one, two) { function check(indexed) { var hint; if (indexed) { - hint = { - a: 1, - b: -1 - }; + hint = {a: 1, b: -1}; } else { - hint = { - $natural: 1 - }; + hint = {$natural: 1}; } f = r.find().sort({a: 1, b: 1}).hint(hint); diff --git a/jstests/core/cursor7.js b/jstests/core/cursor7.js index 6e77a144ba3..7807dbe22f5 100644 --- a/jstests/core/cursor7.js +++ b/jstests/core/cursor7.js @@ -15,14 +15,8 @@ function testMultipleInequalities(db) { z = [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}, {a: 7, b: 8}]; for (i = 0; i < z.length; ++i) r.save(z[i]); - idx = { - a: 1, - b: 1 - }; - rIdx = { - a: -1, - b: -1 - }; + idx = {a: 1, b: 1}; + rIdx = {a: -1, b: -1}; r.ensureIndex(idx); checkResults([z[2], z[3]], r.find({a: {$gt: 3}}).sort(idx).hint(idx)); @@ -33,35 +27,27 @@ function testMultipleInequalities(db) { checkResults([z[2]], r.find({a: {$gt: 3, $lt: 7}}).sort(rIdx).hint(idx)); checkResults([z[2]], r.find({a: {$gt: 3, $lt: 7, $lte: 5}}).sort(rIdx).hint(idx)); - checkResults([z[1], z[2]], - r.find({ - a: {$gt: 1, $lt: 7, $gte: 3, $lte: 5}, - b: {$gt: 2, $lt: 8, $gte: 4, $lte: 6} - }) - .sort(idx) - .hint(idx)); - checkResults([z[2], z[1]], - r.find({ - a: {$gt: 1, $lt: 7, $gte: 3, $lte: 5}, - b: {$gt: 2, $lt: 8, $gte: 4, $lte: 6} - }) - .sort(rIdx) - .hint(idx)); - - checkResults([z[1], z[2]], - r.find({ - a: {$gte: 1, $lte: 7, $gt: 2, $lt: 6}, - b: {$gte: 2, $lte: 8, $gt: 3, $lt: 7} - }) - .sort(idx) - .hint(idx)); - checkResults([z[2], z[1]], - r.find({ - a: {$gte: 1, $lte: 7, $gt: 2, $lt: 6}, - b: {$gte: 2, $lte: 8, $gt: 3, $lt: 7} - }) - .sort(rIdx) - .hint(idx)); + checkResults( + [z[1], z[2]], + r.find({a: {$gt: 1, $lt: 7, $gte: 3, $lte: 5}, b: {$gt: 2, $lt: 8, $gte: 4, $lte: 6}}) + .sort(idx) + .hint(idx)); + checkResults( + [z[2], z[1]], + r.find({a: {$gt: 1, $lt: 7, $gte: 3, $lte: 5}, b: {$gt: 2, $lt: 8, $gte: 4, $lte: 6}}) + .sort(rIdx) + .hint(idx)); + + checkResults( + [z[1], z[2]], + r.find({a: {$gte: 1, $lte: 7, $gt: 2, $lt: 6}, b: {$gte: 2, $lte: 8, $gt: 3, $lt: 7}}) + .sort(idx) + .hint(idx)); + checkResults( + [z[2], z[1]], + r.find({a: {$gte: 1, $lte: 7, $gt: 2, $lt: 6}, b: {$gte: 2, $lte: 8, $gt: 3, $lt: 7}}) + .sort(rIdx) + .hint(idx)); } testMultipleInequalities(db); diff --git a/jstests/core/cursora.js b/jstests/core/cursora.js index dfd9e28f281..1ee0a6d3e69 100644 --- a/jstests/core/cursora.js +++ b/jstests/core/cursora.js @@ -24,11 +24,11 @@ function run(n, atomic) { try { start = new Date(); num = t.find(function() { - num = 2; - for (var x = 0; x < 1000; x++) - num += 2; - return num > 0; - }) + num = 2; + for (var x = 0; x < 1000; x++) + num += 2; + return num > 0; + }) .sort({_id: -1}) .itcount(); end = new Date(); diff --git a/jstests/core/datasize2.js b/jstests/core/datasize2.js index 6cb5b9b10d9..eb79b12a6c4 100644 --- a/jstests/core/datasize2.js +++ b/jstests/core/datasize2.js @@ -15,12 +15,8 @@ coll.insert({_id: i, s: "asdasdasdasdasdasdasd"}); } - var dataSizeCommand = { - "dataSize": "test.foo", - "keyPattern": {"_id": 1}, - "min": {"_id": 0}, - "max": {"_id": N} - }; + var dataSizeCommand = + {"dataSize": "test.foo", "keyPattern": {"_id": 1}, "min": {"_id": 0}, "max": {"_id": N}}; assert.eq(N, db.runCommand(dataSizeCommand).numObjects, diff --git a/jstests/core/date2.js b/jstests/core/date2.js index 2980f10bf7a..15993815b14 100644 --- a/jstests/core/date2.js +++ b/jstests/core/date2.js @@ -5,9 +5,7 @@ t.drop(); t.ensureIndex({a: 1}); -var obj = { - a: new Timestamp(0, 1) -}; // in old versions this was == to new Date(1) +var obj = {a: new Timestamp(0, 1)}; // in old versions this was == to new Date(1) t.save(obj); assert.eq(0, t.find({a: {$gt: new Date(1)}}).itcount()); assert.eq(1, t.find(obj).itcount()); diff --git a/jstests/core/depth_limit.js b/jstests/core/depth_limit.js index ddb648b4586..4e40c114369 100644 --- a/jstests/core/depth_limit.js +++ b/jstests/core/depth_limit.js @@ -17,9 +17,7 @@ function test() { function objWithDepth(depth) { var out = 1; while (depth--) { - out = { - o: out - }; + out = {o: out}; } return out; } diff --git a/jstests/core/distinct_index1.js b/jstests/core/distinct_index1.js index 31faecd376e..026fdca4e0a 100644 --- a/jstests/core/distinct_index1.js +++ b/jstests/core/distinct_index1.js @@ -11,10 +11,7 @@ function d(k, q) { } for (i = 0; i < 1000; i++) { - o = { - a: r(i * 5), - b: r(i) - }; + o = {a: r(i * 5), b: r(i)}; t.insert(o); } diff --git a/jstests/core/doc_validation_invalid_validators.js b/jstests/core/doc_validation_invalid_validators.js index aeebae42820..b78b31c0977 100644 --- a/jstests/core/doc_validation_invalid_validators.js +++ b/jstests/core/doc_validation_invalid_validators.js @@ -23,8 +23,8 @@ assert.commandFailed( db.getSiblingDB("admin").createCollection(collName, {validator: {a: {$exists: true}}})); if (!db.runCommand("isdbgrid").isdbgrid) { - assert.commandFailed(db.getSiblingDB("local") - .createCollection(collName, {validator: {a: {$exists: true}}})); + assert.commandFailed( + db.getSiblingDB("local").createCollection(collName, {validator: {a: {$exists: true}}})); } assert.commandFailed( db.getSiblingDB("config").createCollection(collName, {validator: {a: {$exists: true}}})); diff --git a/jstests/core/dropdb_race.js b/jstests/core/dropdb_race.js index b4666ecc3ad..bd5e7e5ddba 100644 --- a/jstests/core/dropdb_race.js +++ b/jstests/core/dropdb_race.js @@ -14,7 +14,7 @@ var start = new Date(); for (var pass = 0; pass < 100; pass++) { if (pass % 2 == 0) { // sometimes wait for create db first, to vary the timing of things - var options = ( pass % 4 == 0 )? { writeConcern: { fsync: true }} : undefined; + var options = (pass % 4 == 0) ? {writeConcern: {fsync: true}} : undefined; t.insert({}, options); } t.insert({x: 1}); diff --git a/jstests/core/elemMatchProjection.js b/jstests/core/elemMatchProjection.js index 97d1be0f081..e7aa5194607 100644 --- a/jstests/core/elemMatchProjection.js +++ b/jstests/core/elemMatchProjection.js @@ -47,9 +47,8 @@ assert.eq(1, t.find({group: 3, 'x.a': 2}, {'x.$': 1}).toArray()[0].x.length, "single object match (array length match)"); -assert.eq(2, - t.find({group: 3, 'x.a': 1}, {'x.$': 1}).toArray()[0].x[0].b, - "single object match first"); +assert.eq( + 2, t.find({group: 3, 'x.a': 1}, {'x.$': 1}).toArray()[0].x[0].b, "single object match first"); assert.eq(undefined, t.find({group: 3, 'x.a': 2}, {_id: 0, 'x.$': 1}).toArray()[0]._id, @@ -149,9 +148,8 @@ if (false) { // // SERVER-2238: $elemMatch projections // -assert.eq(-6, - t.find({group: 4}, {x: {$elemMatch: {a: -6}}}).toArray()[0].x[0].a, - "single object match"); +assert.eq( + -6, t.find({group: 4}, {x: {$elemMatch: {a: -6}}}).toArray()[0].x[0].a, "single object match"); assert.eq(1, t.find({group: 4}, {x: {$elemMatch: {a: -6}}}).toArray()[0].x.length, @@ -184,9 +182,8 @@ assert.eq([1], // but this may become a user assertion, since a single element of an array can't match more than // one value -assert.eq([1], - t.find({group: 1}, {x: {$elemMatch: {$all: [1]}}}).toArray()[0].x, - "$in number match"); +assert.eq( + [1], t.find({group: 1}, {x: {$elemMatch: {$all: [1]}}}).toArray()[0].x, "$in number match"); assert.eq([{a: 'string', b: date1}], t.find({group: 6}, {x: {$elemMatch: {a: 'string'}}}).toArray()[0].x, @@ -212,10 +209,10 @@ assert.eq([{a: 2, c: 3}], t.find({group: 3}, {x: {$elemMatch: {a: {$mod: [2, 0]}}}}).toArray()[0].x, "mixed object match on mod"); -assert.eq({"x": [{"a": 1, "b": 2}], "y": [{"c": 3, "d": 4}]}, - t.find({group: 10}, {_id: 0, x: {$elemMatch: {a: 1}}, y: {$elemMatch: {c: 3}}}) - .toArray()[0], - "multiple $elemMatch on unique fields 1"); +assert.eq( + {"x": [{"a": 1, "b": 2}], "y": [{"c": 3, "d": 4}]}, + t.find({group: 10}, {_id: 0, x: {$elemMatch: {a: 1}}, y: {$elemMatch: {c: 3}}}).toArray()[0], + "multiple $elemMatch on unique fields 1"); assert.eq({"x": [{"y": [{"a": 1, "b": 2}, {"a": 3, "b": 4}]}]}, t.find({group: 8}, {_id: 0, x: {$elemMatch: {y: {$elemMatch: {a: 3}}}}}).toArray()[0], diff --git a/jstests/core/eval0.js b/jstests/core/eval0.js index a0c93da2cab..57a60e77244 100644 --- a/jstests/core/eval0.js +++ b/jstests/core/eval0.js @@ -4,13 +4,9 @@ assert.eq(17, return 11 + 6; }), "A"); -assert.eq(17, - db.eval( - function(x) { - return 10 + x; - }, - 7), - "B"); +assert.eq(17, db.eval(function(x) { + return 10 + x; +}, 7), "B"); // check that functions in system.js work db.system.js.insert({ diff --git a/jstests/core/eval_mr.js b/jstests/core/eval_mr.js index 84036b1e0d5..4a3dc8dad6c 100644 --- a/jstests/core/eval_mr.js +++ b/jstests/core/eval_mr.js @@ -6,16 +6,15 @@ assert.writeOK(db.eval_mr.insert({val: 1})); assert.writeOK(db.eval_mr.insert({val: 2})); var runBasicMapReduce = function() { - return db.eval_mr.runCommand("mapReduce", - { - map: function() { - emit(0, this.val); - }, - reduce: function(id, values) { - return Array.sum(values); - }, - out: {replace: "eval_mr_out"} - }); + return db.eval_mr.runCommand("mapReduce", { + map: function() { + emit(0, this.val); + }, + reduce: function(id, values) { + return Array.sum(values); + }, + out: {replace: "eval_mr_out"} + }); }; assert.commandWorked(runBasicMapReduce()); assert.eq(3, db.eval_mr_out.findOne().value); diff --git a/jstests/core/evalg.js b/jstests/core/evalg.js index 570464cbce2..18503659217 100644 --- a/jstests/core/evalg.js +++ b/jstests/core/evalg.js @@ -3,10 +3,9 @@ db.evalg.drop(); for (var i = 0; i < 102; ++i) { db.evalg.insert({}); } -assert.eq(102, - db.eval(function() { - var cursor = db.evalg.aggregate(); - assert(cursor.hasNext()); - assert.eq(101, cursor.objsLeftInBatch()); - return cursor.itcount(); - })); +assert.eq(102, db.eval(function() { + var cursor = db.evalg.aggregate(); + assert(cursor.hasNext()); + assert.eq(101, cursor.objsLeftInBatch()); + return cursor.itcount(); +})); diff --git a/jstests/core/exists4.js b/jstests/core/exists4.js index 097a3462da9..2979a60f276 100644 --- a/jstests/core/exists4.js +++ b/jstests/core/exists4.js @@ -34,12 +34,10 @@ assert.eq( 3, t.find({date: new Date("08/27/2010"), country_code: {$exists: true}, user_id: {$exists: true}}) .count()); -assert.eq(2, - t.find({ - date: new Date("08/27/2010"), - country_code: {$exists: true}, - user_id: {$exists: false} - }).count()); -assert.eq(2, - t.find({date: new Date("08/27/2010"), country_code: {$exists: true}, user_id: null}) - .count()); +assert.eq( + 2, + t.find({date: new Date("08/27/2010"), country_code: {$exists: true}, user_id: {$exists: false}}) + .count()); +assert.eq( + 2, + t.find({date: new Date("08/27/2010"), country_code: {$exists: true}, user_id: null}).count()); diff --git a/jstests/core/existsa.js b/jstests/core/existsa.js index 45adb5d3172..e9430b489a3 100644 --- a/jstests/core/existsa.js +++ b/jstests/core/existsa.js @@ -38,9 +38,7 @@ function assertExists(query, expectedExists) { // An $exists:true predicate generates no index filters. Add another predicate on the index key // to trigger use of the index. andClause = {}; - andClause[indexKeyField] = { - $ne: null - }; + andClause[indexKeyField] = {$ne: null}; Object.extend(query, {$and: [andClause]}); assert.eq(expectedExists, t.count(query)); assert.eq(expectedExists, hintedCount(query)); @@ -52,9 +50,7 @@ function assertExistsUnindexed(query, expectedExists) { assert.eq(expectedExists, t.count(query)); // Even with another predicate on the index key, the sparse index is disallowed. andClause = {}; - andClause[indexKeyField] = { - $ne: null - }; + andClause[indexKeyField] = {$ne: null}; Object.extend(query, {$and: [andClause]}); assert.eq(expectedExists, t.count(query)); assert.eq(expectedExists, hintedCount(query)); diff --git a/jstests/core/explain_distinct.js b/jstests/core/explain_distinct.js index bc5b3635c95..57e5f55e065 100644 --- a/jstests/core/explain_distinct.js +++ b/jstests/core/explain_distinct.js @@ -10,10 +10,7 @@ var coll = db[collName]; function runDistinctExplain(collection, keyString, query) { - var distinctCmd = { - distinct: collection.getName(), - key: keyString - }; + var distinctCmd = {distinct: collection.getName(), key: keyString}; if (typeof query !== 'undefined') { distinctCmd.query = query; diff --git a/jstests/core/explain_find.js b/jstests/core/explain_find.js index 820e6dffbcd..87174e99a62 100644 --- a/jstests/core/explain_find.js +++ b/jstests/core/explain_find.js @@ -10,8 +10,8 @@ for (var i = 0; i < 10; i++) { t.insert({_id: i, a: i}); } -var explain = db.runCommand( - {explain: {find: collName, filter: {a: {$lte: 2}}}, verbosity: "executionStats"}); +var explain = + db.runCommand({explain: {find: collName, filter: {a: {$lte: 2}}}, verbosity: "executionStats"}); printjson(explain); assert.commandWorked(explain); assert.eq(3, explain.executionStats.nReturned); diff --git a/jstests/core/explain_find_and_modify.js b/jstests/core/explain_find_and_modify.js index 346e7029cd1..1d30486ecb4 100644 --- a/jstests/core/explain_find_and_modify.js +++ b/jstests/core/explain_find_and_modify.js @@ -13,12 +13,8 @@ var t = db.getCollection(cName); // Different types of findAndModify explain requests. - var explainRemove = { - explain: {findAndModify: cName, remove: true, query: {_id: 0}} - }; - var explainUpdate = { - explain: {findAndModify: cName, update: {$inc: {i: 1}}, query: {_id: 0}} - }; + var explainRemove = {explain: {findAndModify: cName, remove: true, query: {_id: 0}}}; + var explainUpdate = {explain: {findAndModify: cName, update: {$inc: {i: 1}}, query: {_id: 0}}}; var explainUpsert = { explain: {findAndModify: cName, update: {$inc: {i: 1}}, query: {_id: 0}, upsert: true} }; @@ -60,39 +56,24 @@ assert.commandFailed(db.runCommand({remove: true, new: true})); // 4. Explaining findAndModify should not modify any contents of the collection. - var onlyDoc = { - _id: 0, - i: 1 - }; + var onlyDoc = {_id: 0, i: 1}; assert.writeOK(t.insert(onlyDoc)); // Explaining a delete should not delete anything. - var matchingRemoveCmd = { - findAndModify: cName, - remove: true, - query: {_id: onlyDoc._id} - }; + var matchingRemoveCmd = {findAndModify: cName, remove: true, query: {_id: onlyDoc._id}}; var res = db.runCommand({explain: matchingRemoveCmd}); assert.commandWorked(res); assert.eq(t.find().itcount(), 1, "Explaining a remove should not remove any documents."); // Explaining an update should not update anything. - var matchingUpdateCmd = { - findAndModify: cName, - update: {x: "x"}, - query: {_id: onlyDoc._id} - }; + var matchingUpdateCmd = {findAndModify: cName, update: {x: "x"}, query: {_id: onlyDoc._id}}; var res = db.runCommand({explain: matchingUpdateCmd}); assert.commandWorked(res); assert.eq(t.findOne(), onlyDoc, "Explaining an update should not update any documents."); // Explaining an upsert should not insert anything. - var matchingUpsertCmd = { - findAndModify: cName, - update: {x: "x"}, - query: {_id: "non-match"}, - upsert: true - }; + var matchingUpsertCmd = + {findAndModify: cName, update: {x: "x"}, query: {_id: "non-match"}, upsert: true}; var res = db.runCommand({explain: matchingUpsertCmd}); assert.commandWorked(res); assert.eq(t.find().itcount(), 1, "Explaining an upsert should not insert any documents."); @@ -273,23 +254,21 @@ function assertExplainResultsMatch(explainOut, expectedMatches, preMsg, currentPath) { // This is only used recursively, to keep track of where we are in the document. var isRootLevel = typeof currentPath === "undefined"; - Object.keys(expectedMatches) - .forEach(function(key) { - var totalFieldName = isRootLevel ? key : currentPath + "." + key; - assert(explainOut.hasOwnProperty(key), - preMsg + "Explain's output does not have a value for " + key); - if (typeof expectedMatches[key] === "object") { - // Sub-doc, recurse to match on it's fields - assertExplainResultsMatch( - explainOut[key], expectedMatches[key], preMsg, totalFieldName); - } else { - assert.eq(explainOut[key], - expectedMatches[key], - preMsg + "Explain's " + totalFieldName + " (" + explainOut[key] + - ")" + " does not match expected value (" + expectedMatches[key] + - ")."); - } - }); + Object.keys(expectedMatches).forEach(function(key) { + var totalFieldName = isRootLevel ? key : currentPath + "." + key; + assert(explainOut.hasOwnProperty(key), + preMsg + "Explain's output does not have a value for " + key); + if (typeof expectedMatches[key] === "object") { + // Sub-doc, recurse to match on it's fields + assertExplainResultsMatch( + explainOut[key], expectedMatches[key], preMsg, totalFieldName); + } else { + assert.eq(explainOut[key], + expectedMatches[key], + preMsg + "Explain's " + totalFieldName + " (" + explainOut[key] + ")" + + " does not match expected value (" + expectedMatches[key] + ")."); + } + }); } /** diff --git a/jstests/core/explain_multi_plan.js b/jstests/core/explain_multi_plan.js index f74078c717d..693237d9edc 100644 --- a/jstests/core/explain_multi_plan.js +++ b/jstests/core/explain_multi_plan.js @@ -49,13 +49,12 @@ }); assert.doesNotThrow(function() { - coll.explain("allPlansExecution") - .group({ - key: {a: 1}, - cond: {a: {$gte: 1}}, - reduce: function(curr, result) {}, - initial: {} - }); + coll.explain("allPlansExecution").group({ + key: {a: 1}, + cond: {a: {$gte: 1}}, + reduce: function(curr, result) {}, + initial: {} + }); }); // SERVER-21376: Make sure the 'rejectedPlans' field is filled in appropriately. diff --git a/jstests/core/find4.js b/jstests/core/find4.js index 7a5ebf79578..204e7c511e2 100644 --- a/jstests/core/find4.js +++ b/jstests/core/find4.js @@ -23,9 +23,11 @@ t.drop(); t.save({a: 1, b: 1}); t.save({a: 2, b: 2}); assert.eq("1-1,2-2", - t.find().map(function(z) { - return z.a + "-" + z.b; - }).toString()); + t.find() + .map(function(z) { + return z.a + "-" + z.b; + }) + .toString()); assert.eq("1-undefined,2-undefined", t.find({}, {a: 1}) .map(function(z) { diff --git a/jstests/core/find_and_modify.js b/jstests/core/find_and_modify.js index cf2f8804d9e..394b618f109 100644 --- a/jstests/core/find_and_modify.js +++ b/jstests/core/find_and_modify.js @@ -69,7 +69,8 @@ var cmdRes = db.runCommand({ query: {_id: "miss"}, update: {$inc: {y: 1}}, fields: {foo: {$pop: ["bar"]}}, - upsert: true, new: true + upsert: true, + new: true }); assert.commandFailed(cmdRes); @@ -81,7 +82,8 @@ cmdRes = db.runCommand({ query: {_id: "found"}, update: {$inc: {y: 1}}, fields: {foo: {$pop: ["bar"]}}, - upsert: true, new: true + upsert: true, + new: true }); assert.commandFailed(cmdRes); @@ -90,7 +92,8 @@ cmdRes = db.runCommand({ findAndModify: t.getName(), query: {_id: "found"}, update: {$inc: {y: 1}}, - fields: {foo: {$pop: ["bar"]}}, new: true + fields: {foo: {$pop: ["bar"]}}, + new: true }); assert.commandFailed(cmdRes); @@ -128,7 +131,8 @@ cmdRes = db.runCommand({ findAndModify: t.getName(), query: {_id: "missagain"}, update: {$inc: {y: 1}}, - upsert: true, new: true + upsert: true, + new: true }); assert.commandWorked(cmdRes); assert("value" in cmdRes); diff --git a/jstests/core/find_and_modify_server6865.js b/jstests/core/find_and_modify_server6865.js index b38c0b1bee4..3583da42412 100644 --- a/jstests/core/find_and_modify_server6865.js +++ b/jstests/core/find_and_modify_server6865.js @@ -69,66 +69,60 @@ {_id: 42, c: 4}); // Simple query that uses $elemMatch in the projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - {query: {_id: 42}, fields: {b: {$elemMatch: {value: 2}}}, remove: true}, - {_id: 42, b: [{name: 'second', value: 2}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + {query: {_id: 42}, fields: {b: {$elemMatch: {value: 2}}}, remove: true}, + {_id: 42, b: [{name: 'second', value: 2}]}); // Query on an array of values while using a positional projection. - testFAMWorked({_id: 42, a: [1, 2]}, - {query: {a: 2}, fields: {'a.$': 1}, remove: true}, - {_id: 42, a: [2]}); + testFAMWorked( + {_id: 42, a: [1, 2]}, {query: {a: 2}, fields: {'a.$': 1}, remove: true}, {_id: 42, a: [2]}); // Query on an array of objects while using a positional projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$': 1}, remove: true}, - {_id: 42, b: [{name: 'third', value: 3}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$': 1}, remove: true}, + {_id: 42, b: [{name: 'third', value: 3}]}); // Query on an array of objects while using a position projection. // Verifies that the projection {'b.$.value': 1} is treated the // same as {'b.$': 1}. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$.value': 1}, remove: true}, - {_id: 42, b: [{name: 'third', value: 3}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$.value': 1}, remove: true}, + {_id: 42, b: [{name: 'third', value: 3}]}); // Query on an array of objects using $elemMatch while using an inclusion projection. - testFAMWorked( - { - _id: 42, - a: 5, - b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] - }, - { - query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, - fields: {_id: 0, a: 5}, - remove: true - }, - {a: 5}); + testFAMWorked({ + _id: 42, + a: 5, + b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] + }, + { + query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, + fields: {_id: 0, a: 5}, + remove: true + }, + {a: 5}); // Query on an array of objects using $elemMatch while using the positional // operator in the projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] - }, - { - query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, - fields: {_id: 0, 'b.$': 1}, - remove: true - }, - {b: [{name: 'john', value: 1}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] + }, + { + query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, + fields: {_id: 0, 'b.$': 1}, + remove: true + }, + {b: [{name: 'john', value: 1}]}); // // Update operations with new=false @@ -145,17 +139,17 @@ {_id: 42, c: 4}); // Simple query that uses $elemMatch in the projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - { - query: {_id: 42}, - fields: {b: {$elemMatch: {value: 2}}}, - update: {$set: {name: '2nd'}}, new: false - }, - {_id: 42, b: [{name: 'second', value: 2}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + { + query: {_id: 42}, + fields: {b: {$elemMatch: {value: 2}}}, + update: {$set: {name: '2nd'}}, + new: false + }, + {_id: 42, b: [{name: 'second', value: 2}]}); // Query on an array of values while using a positional projection. testFAMWorked( @@ -164,17 +158,17 @@ {_id: 42, a: [2]}); // Query on an array of objects while using a positional projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - { - query: {_id: 42, 'b.name': 'third'}, - fields: {'b.$': 1}, - update: {$set: {'b.$.kind': 'xyz'}}, new: false - }, - {_id: 42, b: [{name: 'third', value: 3}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + { + query: {_id: 42, 'b.name': 'third'}, + fields: {'b.$': 1}, + update: {$set: {'b.$.kind': 'xyz'}}, + new: false + }, + {_id: 42, b: [{name: 'third', value: 3}]}); // Query on an array of objects while using $elemMatch in the projection, // where the matched array element is modified. @@ -184,32 +178,32 @@ {_id: 1, a: [{x: 1, y: 1}]}); // Query on an array of objects using $elemMatch while using an inclusion projection. - testFAMWorked( - { - _id: 42, - a: 5, - b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] - }, - { - query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, - fields: {_id: 0, a: 5}, - update: {$inc: {a: 6}}, new: false - }, - {a: 5}); + testFAMWorked({ + _id: 42, + a: 5, + b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] + }, + { + query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, + fields: {_id: 0, a: 5}, + update: {$inc: {a: 6}}, + new: false + }, + {a: 5}); // Query on an array of objects using $elemMatch while using the positional // operator in the projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] - }, - { - query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, - fields: {_id: 0, 'b.$': 1}, - update: {$set: {name: 'james'}}, new: false - }, - {b: [{name: 'john', value: 1}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] + }, + { + query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, + fields: {_id: 0, 'b.$': 1}, + update: {$set: {name: 'james'}}, + new: false + }, + {b: [{name: 'john', value: 1}]}); // // Update operations with new=true @@ -226,17 +220,17 @@ {_id: 42, c: 5}); // Simple query that uses $elemMatch in the projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - { - query: {_id: 42}, - fields: {b: {$elemMatch: {value: 2}}}, - update: {$set: {'b.1.name': '2nd'}}, new: true - }, - {_id: 42, b: [{name: '2nd', value: 2}]}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + { + query: {_id: 42}, + fields: {b: {$elemMatch: {value: 2}}}, + update: {$set: {'b.1.name': '2nd'}}, + new: true + }, + {_id: 42, b: [{name: '2nd', value: 2}]}); // Query on an array of values while using a positional projection. testFAMFailed( @@ -244,29 +238,29 @@ {query: {a: 2}, fields: {'a.$': 1}, update: {$set: {'b.kind': 'xyz'}}, new: true}); // Query on an array of objects while using a positional projection. - testFAMFailed( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - { - query: {_id: 42, 'b.name': 'third'}, - fields: {'b.$': 1}, - update: {$set: {'b.$.kind': 'xyz'}}, new: true - }); + testFAMFailed({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + { + query: {_id: 42, 'b.name': 'third'}, + fields: {'b.$': 1}, + update: {$set: {'b.$.kind': 'xyz'}}, + new: true + }); // Query on an array of objects while using $elemMatch in the projection. - testFAMWorked( - { - _id: 42, - b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] - }, - { - query: {_id: 42}, - fields: {b: {$elemMatch: {value: 2}}, c: 1}, - update: {$set: {c: 'xyz'}}, new: true - }, - {_id: 42, b: [{name: 'second', value: 2}], c: 'xyz'}); + testFAMWorked({ + _id: 42, + b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}] + }, + { + query: {_id: 42}, + fields: {b: {$elemMatch: {value: 2}}, c: 1}, + update: {$set: {c: 'xyz'}}, + new: true + }, + {_id: 42, b: [{name: 'second', value: 2}], c: 'xyz'}); // Query on an array of objects while using $elemMatch in the projection, // where the matched array element is modified. @@ -276,30 +270,30 @@ {_id: 1, a: [{x: 1, y: 2}]}); // Query on an array of objects using $elemMatch while using an inclusion projection. - testFAMWorked( - { - _id: 42, - a: 5, - b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] - }, - { - query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, - fields: {_id: 0, a: 5}, - update: {$inc: {a: 6}}, new: true - }, - {a: 11}); + testFAMWorked({ + _id: 42, + a: 5, + b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] + }, + { + query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, + fields: {_id: 0, a: 5}, + update: {$inc: {a: 6}}, + new: true + }, + {a: 11}); // Query on an array of objects using $elemMatch while using the positional // operator in the projection. - testFAMFailed( - { - _id: 42, - b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] - }, - { - query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, - fields: {_id: 0, 'b.$': 1}, - update: {$set: {name: 'james'}}, new: true - }); + testFAMFailed({ + _id: 42, + b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}] + }, + { + query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}}, + fields: {_id: 0, 'b.$': 1}, + update: {$set: {name: 'james'}}, + new: true + }); })(); diff --git a/jstests/core/find_dedup.js b/jstests/core/find_dedup.js index a9160df7562..7a489bd185c 100644 --- a/jstests/core/find_dedup.js +++ b/jstests/core/find_dedup.js @@ -20,15 +20,14 @@ t.save({_id: 2, a: 1, b: 1}); t.save({_id: 3, a: 2, b: 2}); t.save({_id: 4, a: 3, b: 3}); t.save({_id: 5, a: 3, b: 3}); -checkDedup( - { - $or: [ - {a: {$gte: 0, $lte: 2}, b: {$gte: 0, $lte: 2}}, - {a: {$gte: 1, $lte: 3}, b: {$gte: 1, $lte: 3}}, - {a: {$gte: 1, $lte: 4}, b: {$gte: 1, $lte: 4}} - ] - }, - [1, 2, 3, 4, 5]); +checkDedup({ + $or: [ + {a: {$gte: 0, $lte: 2}, b: {$gte: 0, $lte: 2}}, + {a: {$gte: 1, $lte: 3}, b: {$gte: 1, $lte: 3}}, + {a: {$gte: 1, $lte: 4}, b: {$gte: 1, $lte: 4}} + ] +}, + [1, 2, 3, 4, 5]); // Deduping multikey t.drop(); diff --git a/jstests/core/find_getmore_bsonsize.js b/jstests/core/find_getmore_bsonsize.js index 904a9c33ab0..fdad2b1f1d6 100644 --- a/jstests/core/find_getmore_bsonsize.js +++ b/jstests/core/find_getmore_bsonsize.js @@ -74,10 +74,7 @@ bigStr += bigStr; } bigStr = bigStr.substring(0, (16 * oneMB) - 32); - var maxSizeDoc = { - _id: 0, - padding: bigStr - }; + var maxSizeDoc = {_id: 0, padding: bigStr}; assert.eq(Object.bsonsize(maxSizeDoc), 16 * oneMB); assert.writeOK(coll.insert(maxSizeDoc)); diff --git a/jstests/core/fts_blog.js b/jstests/core/fts_blog.js index 9f35836ef37..68cca6fa3a5 100644 --- a/jstests/core/fts_blog.js +++ b/jstests/core/fts_blog.js @@ -9,8 +9,9 @@ t.save({_id: 3, title: "knives are Fun", text: "this is a new blog i am writing. // specify weights if you want a field to be more meaningull t.ensureIndex({"title": "text", text: "text"}, {weights: {title: 10}}); -res = t.find({"$text": {"$search": "blog"}}, {score: {"$meta": "textScore"}}) - .sort({score: {"$meta": "textScore"}}); +res = t.find({"$text": {"$search": "blog"}}, {score: {"$meta": "textScore"}}).sort({ + score: {"$meta": "textScore"} +}); assert.eq(3, res.length()); assert.eq(1, res[0]._id); diff --git a/jstests/core/fts_blogwild.js b/jstests/core/fts_blogwild.js index dad96cd2836..377e4529f3e 100644 --- a/jstests/core/fts_blogwild.js +++ b/jstests/core/fts_blogwild.js @@ -24,17 +24,20 @@ t.dropIndex("dummy_text"); assert.eq(1, t.getIndexKeys().length, "C1"); t.ensureIndex({dummy: "text"}, {weights: {"$**": 1, title: 2}}); -res = t.find({"$text": {"$search": "write"}}, {score: {"$meta": "textScore"}}) - .sort({score: {"$meta": "textScore"}}); +res = t.find({"$text": {"$search": "write"}}, {score: {"$meta": "textScore"}}).sort({ + score: {"$meta": "textScore"} +}); assert.eq(3, res.length(), "C2"); assert.eq(3, res[0]._id, "C3"); -res = t.find({"$text": {"$search": "blog"}}, {score: {"$meta": "textScore"}}) - .sort({score: {"$meta": "textScore"}}); +res = t.find({"$text": {"$search": "blog"}}, {score: {"$meta": "textScore"}}).sort({ + score: {"$meta": "textScore"} +}); assert.eq(3, res.length(), "D1"); assert.eq(1, res[0]._id, "D2"); -res = t.find({"$text": {"$search": "eliot"}}, {score: {"$meta": "textScore"}}) - .sort({score: {"$meta": "textScore"}}); +res = t.find({"$text": {"$search": "eliot"}}, {score: {"$meta": "textScore"}}).sort({ + score: {"$meta": "textScore"} +}); assert.eq(2, res.length(), "E1"); assert.eq(3, res[0]._id, "E2"); diff --git a/jstests/core/fts_diacritic_and_casesensitive.js b/jstests/core/fts_diacritic_and_casesensitive.js index 397b6033f88..d5c15034dbc 100644 --- a/jstests/core/fts_diacritic_and_casesensitive.js +++ b/jstests/core/fts_diacritic_and_casesensitive.js @@ -19,8 +19,8 @@ load('jstests/libs/fts.js'); assert.eq( [0], queryIDS(coll, "próximo vôo à", null, {$diacriticSensitive: true, $caseSensitive: true})); - assert.eq( - [0], queryIDS(coll, "Atlântico", null, {$diacriticSensitive: true, $caseSensitive: true})); + assert.eq([0], + queryIDS(coll, "Atlântico", null, {$diacriticSensitive: true, $caseSensitive: true})); assert.eq( [0], queryIDS(coll, "\"próximo\"", null, {$diacriticSensitive: true, $caseSensitive: true})); @@ -47,8 +47,7 @@ load('jstests/libs/fts.js'); queryIDS(coll, "proximo vôo à", null, {$diacriticSensitive: true, $caseSensitive: true})); assert.eq( [], - queryIDS( - coll, "À -próximo -Vôo", null, {$diacriticSensitive: true, $caseSensitive: true})); + queryIDS(coll, "À -próximo -Vôo", null, {$diacriticSensitive: true, $caseSensitive: true})); assert.eq( [], queryIDS(coll, "à proximo -Vôo", null, {$diacriticSensitive: true, $caseSensitive: true})); diff --git a/jstests/core/fts_diacriticsensitive.js b/jstests/core/fts_diacriticsensitive.js index 29e7784a785..e21d5360051 100644 --- a/jstests/core/fts_diacriticsensitive.js +++ b/jstests/core/fts_diacriticsensitive.js @@ -24,8 +24,7 @@ load('jstests/libs/fts.js'); assert.eq([0], queryIDS(coll, "\"próximo\"", null, {$diacriticSensitive: true})); assert.eq([0], queryIDS(coll, "\"põe\" atlântico", null, {$diacriticSensitive: true})); assert.eq( - [0], - queryIDS(coll, "\"próximo vôo\" \"único médico\"", null, {$diacriticSensitive: true})); + [0], queryIDS(coll, "\"próximo vôo\" \"único médico\"", null, {$diacriticSensitive: true})); assert.eq( [0], queryIDS(coll, "\"próximo vôo\" -\"unico médico\"", null, {$diacriticSensitive: true})); @@ -38,7 +37,6 @@ load('jstests/libs/fts.js'); assert.eq([], queryIDS(coll, "mo vô", null, {$diacriticSensitive: true})); assert.eq([], queryIDS(coll, "\"unico medico\"", null, {$diacriticSensitive: true})); assert.eq( - [], - queryIDS(coll, "\"próximo vôo\" -\"único médico\"", null, {$diacriticSensitive: true})); + [], queryIDS(coll, "\"próximo vôo\" -\"único médico\"", null, {$diacriticSensitive: true})); })(); diff --git a/jstests/core/fts_index.js b/jstests/core/fts_index.js index 8cda28096d2..ab953a88624 100644 --- a/jstests/core/fts_index.js +++ b/jstests/core/fts_index.js @@ -17,48 +17,60 @@ coll.getDB().createCollection(coll.getName()); // Spec passes text-specific index validation. assert.commandWorked(coll.ensureIndex({a: "text"}, {name: indexName, default_language: "spanish"})); assert.eq(1, - coll.getIndexes().filter(function(z) { - return z.name == indexName; - }).length); + coll.getIndexes() + .filter(function(z) { + return z.name == indexName; + }) + .length); coll.dropIndexes(); // Spec fails text-specific index validation ("spanglish" unrecognized). -assert.commandFailed(coll.ensureIndex({a: "text"}, - {name: indexName, default_language: "spanglish"})); +assert.commandFailed( + coll.ensureIndex({a: "text"}, {name: indexName, default_language: "spanglish"})); assert.eq(0, - coll.getIndexes().filter(function(z) { - return z.name == indexName; - }).length); + coll.getIndexes() + .filter(function(z) { + return z.name == indexName; + }) + .length); coll.dropIndexes(); // Spec passes general index validation. assert.commandWorked(coll.ensureIndex({"$**": "text"}, {name: indexName})); assert.eq(1, - coll.getIndexes().filter(function(z) { - return z.name == indexName; - }).length); + coll.getIndexes() + .filter(function(z) { + return z.name == indexName; + }) + .length); coll.dropIndexes(); // Spec fails general index validation ("a.$**" invalid field name for key). assert.commandFailed(coll.ensureIndex({"a.$**": "text"}, {name: indexName})); assert.eq(0, - coll.getIndexes().filter(function(z) { - return z.name == indexName; - }).length); + coll.getIndexes() + .filter(function(z) { + return z.name == indexName; + }) + .length); coll.dropIndexes(); // SERVER-19519 Spec fails if '_fts' is specified on a non-text index. assert.commandFailed(coll.ensureIndex({_fts: 1}, {name: indexName})); assert.eq(0, - coll.getIndexes().filter(function(z) { - return z.name == indexName; - }).length); + coll.getIndexes() + .filter(function(z) { + return z.name == indexName; + }) + .length); coll.dropIndexes(); assert.commandFailed(coll.ensureIndex({_fts: "text"}, {name: indexName})); assert.eq(0, - coll.getIndexes().filter(function(z) { - return z.name == indexName; - }).length); + coll.getIndexes() + .filter(function(z) { + return z.name == indexName; + }) + .length); coll.dropIndexes(); // diff --git a/jstests/core/fts_phrase.js b/jstests/core/fts_phrase.js index d36df8aaeb0..d93e53b0898 100644 --- a/jstests/core/fts_phrase.js +++ b/jstests/core/fts_phrase.js @@ -8,14 +8,16 @@ t.save({_id: 3, title: "knives are Fun", text: "this is a new blog i am writing. t.ensureIndex({"title": "text", text: "text"}, {weights: {title: 10}}); -res = t.find({"$text": {"$search": "blog write"}}, {score: {"$meta": "textScore"}}) - .sort({score: {"$meta": "textScore"}}); +res = t.find({"$text": {"$search": "blog write"}}, {score: {"$meta": "textScore"}}).sort({ + score: {"$meta": "textScore"} +}); assert.eq(3, res.length()); assert.eq(1, res[0]._id); assert(res[0].score > (res[1].score * 2), tojson(res.toArray())); -res = t.find({"$text": {"$search": "write blog"}}, {score: {"$meta": "textScore"}}) - .sort({score: {"$meta": "textScore"}}); +res = t.find({"$text": {"$search": "write blog"}}, {score: {"$meta": "textScore"}}).sort({ + score: {"$meta": "textScore"} +}); assert.eq(3, res.length()); assert.eq(1, res[0]._id); assert(res[0].score > (res[1].score * 2), tojson(res.toArray())); diff --git a/jstests/core/fts_projection.js b/jstests/core/fts_projection.js index 50fe4755fc3..6cb1471505b 100644 --- a/jstests/core/fts_projection.js +++ b/jstests/core/fts_projection.js @@ -11,8 +11,10 @@ t.insert({_id: 2, a: "irrelevant content"}); t.ensureIndex({a: "text"}); // Project the text score. -var results = t.find({$text: {$search: "textual content -irrelevant"}}, - {_idCopy: 0, score: {$meta: "textScore"}}).toArray(); +var results = t.find({$text: {$search: "textual content -irrelevant"}}, { + _idCopy: 0, + score: {$meta: "textScore"} + }).toArray(); // printjson(results); // Scores should exist. assert.eq(results.length, 2); @@ -29,8 +31,10 @@ scores[results[1]._id] = results[1].score; // // Project text score into 2 fields. -results = t.find({$text: {$search: "textual content -irrelevant"}}, - {otherScore: {$meta: "textScore"}, score: {$meta: "textScore"}}).toArray(); +results = t.find({$text: {$search: "textual content -irrelevant"}}, { + otherScore: {$meta: "textScore"}, + score: {$meta: "textScore"} + }).toArray(); assert.eq(2, results.length); for (var i = 0; i < results.length; ++i) { assert.close(scores[results[i]._id], results[i].score); @@ -41,8 +45,9 @@ for (var i = 0; i < results.length; ++i) { // Project text score into "x.$" shouldn't crash assert.throws(function() { - t.find({$text: {$search: "textual content -irrelevant"}}, {'x.$': {$meta: "textScore"}}) - .toArray(); + t.find({$text: {$search: "textual content -irrelevant"}}, { + 'x.$': {$meta: "textScore"} + }).toArray(); }); // TODO: We can't project 'x.y':1 and 'x':1 (yet). @@ -71,8 +76,10 @@ assert.throws(function() { // SERVER-12173 // When $text operator is in $or, should evaluate first -results = t.find({$or: [{$text: {$search: "textual content -irrelevant"}}, {_id: 1}]}, - {_idCopy: 0, score: {$meta: "textScore"}}).toArray(); +results = t.find({$or: [{$text: {$search: "textual content -irrelevant"}}, {_id: 1}]}, { + _idCopy: 0, + score: {$meta: "textScore"} + }).toArray(); printjson(results); assert.eq(2, results.length); for (var i = 0; i < results.length; ++i) { diff --git a/jstests/core/geo10.js b/jstests/core/geo10.js index 10879fc5d80..640ae67e594 100644 --- a/jstests/core/geo10.js +++ b/jstests/core/geo10.js @@ -10,7 +10,13 @@ assert.writeOK(db.geo10.insert({c: [1, 1], t: 1})); assert.writeOK(db.geo10.insert({c: [3600, 3600], t: 1})); assert.writeOK(db.geo10.insert({c: [0.001, 0.001], t: 1})); -printjson(db.geo10.find({ - c: {$within: {$box: [[0.001, 0.001], [Math.pow(2, 40) - 0.001, Math.pow(2, 40) - 0.001]]}}, - t: 1 -}).toArray()); +printjson( + db.geo10 + .find({ + c: { + $within: + {$box: [[0.001, 0.001], [Math.pow(2, 40) - 0.001, Math.pow(2, 40) - 0.001]]} + }, + t: 1 + }) + .toArray()); diff --git a/jstests/core/geo3.js b/jstests/core/geo3.js index da3d8641049..feb93b783cb 100644 --- a/jstests/core/geo3.js +++ b/jstests/core/geo3.js @@ -29,9 +29,7 @@ filtered1.results.forEach(function(z) { function avgA(q, len) { if (!len) len = 10; - var realq = { - loc: {$near: [50, 50]} - }; + var realq = {loc: {$near: [50, 50]}}; if (q) Object.extend(realq, q); var as = t.find(realq).limit(len).map(function(z) { diff --git a/jstests/core/geo9.js b/jstests/core/geo9.js index 201bee7dfa5..7419615818e 100644 --- a/jstests/core/geo9.js +++ b/jstests/core/geo9.js @@ -15,9 +15,7 @@ t.ensureIndex({b: "2d"}); function check(field) { var q = {}; - q[field] = { - $near: [11, 11] - }; + q[field] = {$near: [11, 11]}; arr = t.find(q).limit(3).map(function(z) { return Geo.distance([11, 11], z[field]); }); diff --git a/jstests/core/geo_2d_with_geojson_point.js b/jstests/core/geo_2d_with_geojson_point.js index aaadf4be333..23592e004f8 100644 --- a/jstests/core/geo_2d_with_geojson_point.js +++ b/jstests/core/geo_2d_with_geojson_point.js @@ -6,10 +6,7 @@ var t = db.geo_2d_with_geojson_point; t.drop(); t.ensureIndex({loc: '2d'}); -var geoJSONPoint = { - type: 'Point', - coordinates: [0, 0] -}; +var geoJSONPoint = {type: 'Point', coordinates: [0, 0]}; print(assert.throws(function() { t.findOne({loc: {$near: {$geometry: geoJSONPoint}}}); diff --git a/jstests/core/geo_array2.js b/jstests/core/geo_array2.js index 33aad98930a..6195e038de3 100644 --- a/jstests/core/geo_array2.js +++ b/jstests/core/geo_array2.js @@ -40,8 +40,7 @@ for (var t = 0; t < 2; t++) { // Do near check var nearResults = - db.runCommand( - {geoNear: "geoarray2", near: center, num: count, query: {type: type}}) + db.runCommand({geoNear: "geoarray2", near: center, num: count, query: {type: type}}) .results; // printjson( nearResults ) @@ -76,10 +75,11 @@ for (var t = 0; t < 2; t++) { // Earth Radius from geoconstants.h var eRad = 6378.1; - nearResults = db.geoarray2.find({ - loc: {$nearSphere: center, $maxDistance: 500 /* km */ / eRad}, - type: type - }).toArray(); + nearResults = + db.geoarray2 + .find( + {loc: {$nearSphere: center, $maxDistance: 500 /* km */ / eRad}, type: type}) + .toArray(); assert.eq(nearResults.length, count); diff --git a/jstests/core/geo_big_polygon.js b/jstests/core/geo_big_polygon.js index 6f278c59147..9371e1954b2 100644 --- a/jstests/core/geo_big_polygon.js +++ b/jstests/core/geo_big_polygon.js @@ -9,10 +9,7 @@ coll.drop(); coll.getMongo().getDB("admin").runCommand({setParameter: 1, verboseQueryLogging: true}); -var bigCRS = { - type: "name", - properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"} -}; +var bigCRS = {type: "name", properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"}}; var bigPoly20 = { type: "Polygon", @@ -36,20 +33,11 @@ var line10 = { coordinates: [[5.0, 5.0], [5.0, -5.0], [-5.0, -5.0], [-5.0, 5.0], [5.0, 5.0]] }; -var centerPoint = { - type: "Point", - coordinates: [0, 0] -}; +var centerPoint = {type: "Point", coordinates: [0, 0]}; -var polarPoint = { - type: "Point", - coordinates: [85, 85] -}; +var polarPoint = {type: "Point", coordinates: [85, 85]}; -var lineEquator = { - type: "LineString", - coordinates: [[-20, 0], [20, 0]] -}; +var lineEquator = {type: "LineString", coordinates: [[-20, 0], [20, 0]]}; assert.writeOK(coll.insert({loc: poly10})); assert.writeOK(coll.insert({loc: line10})); @@ -100,16 +88,8 @@ assert.commandWorked(coll.ensureIndex({loc: "2dsphere"})); assert.writeError(coll.insert({_id: "bigPoly10", loc: bigPoly10})); // Query geometries that don't support big CRS should error out. -var bigPoint = { - type: "Point", - coordinates: [0, 0], - crs: bigCRS -}; -var bigLine = { - type: "LineString", - coordinates: [[-20, 0], [20, 0]], - crs: bigCRS -}; +var bigPoint = {type: "Point", coordinates: [0, 0], crs: bigCRS}; +var bigLine = {type: "LineString", coordinates: [[-20, 0], [20, 0]], crs: bigCRS}; assert.throws(function() { coll.find({loc: {$geoIntersects: {$geometry: bigPoint}}}).itcount(); diff --git a/jstests/core/geo_big_polygon2.js b/jstests/core/geo_big_polygon2.js index 46ac327b7e0..2193229990d 100644 --- a/jstests/core/geo_big_polygon2.js +++ b/jstests/core/geo_big_polygon2.js @@ -5,23 +5,11 @@ // - Big polygon objects cannot be stored // Try all different shapes queries against various stored geo points, line & polygons -var crs84CRS = { - type: "name", - properties: {name: "urn:ogc:def:crs:OGC:1.3:CRS84"} -}; -var epsg4326CRS = { - type: "name", - properties: {name: "EPSG:4326"} -}; -var strictCRS = { - type: "name", - properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"} -}; +var crs84CRS = {type: "name", properties: {name: "urn:ogc:def:crs:OGC:1.3:CRS84"}}; +var epsg4326CRS = {type: "name", properties: {name: "EPSG:4326"}}; +var strictCRS = {type: "name", properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"}}; // invalid CRS name -var badCRS = { - type: "name", - properties: {name: "urn:x-mongodb:crs:invalid:EPSG:4326"} -}; +var badCRS = {type: "name", properties: {name: "urn:x-mongodb:crs:invalid:EPSG:4326"}}; // helper to generate a line along a longitudinal function genLonLine(lon, startLat, endLat, latStep) { @@ -206,8 +194,7 @@ var objects = [ }, { name: "two points (MultiPoint) but only one in: Shenzhen, Guangdong, China", - geo: - {type: "MultiPoint", coordinates: [[114.0538788, 22.5551603], [113.743858, 23.025815]]} + geo: {type: "MultiPoint", coordinates: [[114.0538788, 22.5551603], [113.743858, 23.025815]]} }, { name: "multi line string: new zealand bays", @@ -606,9 +593,7 @@ indexes.forEach(function(index) { // geoWithin query var docArray = []; - var q = { - geo: {$geoWithin: {$geometry: p}} - }; + var q = {geo: {$geoWithin: {$geometry: p}}}; // Test query in aggregate docArray = coll.aggregate({$match: q}).toArray(); assert.eq(p.nW, docArray.length, "aggregate within " + p.name); @@ -616,9 +601,7 @@ indexes.forEach(function(index) { assert.eq(p.nW, docArray.length, "within " + p.name); // geoIntersects query - q = { - geo: {$geoIntersects: {$geometry: p}} - }; + q = {geo: {$geoIntersects: {$geometry: p}}}; // Test query in aggregate docArray = coll.aggregate({$match: q}).toArray(); assert.eq(p.nI, docArray.length, "aggregate intersects " + p.name); diff --git a/jstests/core/geo_big_polygon3.js b/jstests/core/geo_big_polygon3.js index 049064ebc5b..cd59ed7a2fb 100644 --- a/jstests/core/geo_big_polygon3.js +++ b/jstests/core/geo_big_polygon3.js @@ -10,18 +10,9 @@ // MapReduce with a big polygon // CRS84 & EPSG4326 objects should be retrieved from query with big polygon -var crs84CRS = { - type: "name", - properties: {name: "urn:ogc:def:crs:OGC:1.3:CRS84"} -}; -var epsg4326CRS = { - type: "name", - properties: {name: "EPSG:4326"} -}; -var strictCRS = { - type: "name", - properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"} -}; +var crs84CRS = {type: "name", properties: {name: "urn:ogc:def:crs:OGC:1.3:CRS84"}}; +var epsg4326CRS = {type: "name", properties: {name: "EPSG:4326"}}; +var strictCRS = {type: "name", properties: {name: "urn:x-mongodb:crs:strictwinding:EPSG:4326"}}; var coll = db.geo_bigpoly_edgecases; coll.drop(); @@ -125,12 +116,9 @@ objects = [ name: "NYC - Times Square to CitiField to JFK to Times Square - polygon", geo: { type: "Polygon", - coordinates: [[ - [-73.9857, 40.7577], - [-73.7789, 40.6397], - [-73.8458, 40.7569], - [-73.9857, 40.7577] - ]], + coordinates: [ + [[-73.9857, 40.7577], [-73.7789, 40.6397], [-73.8458, 40.7569], [-73.9857, 40.7577]] + ], crs: strictCRS } } @@ -150,9 +138,8 @@ var poly = { crs: strictCRS }; -assert.eq(0, - coll.count({geo: {$geoWithin: {$geometry: poly}}}), - "ignore objects with strictCRS within"); +assert.eq( + 0, coll.count({geo: {$geoWithin: {$geometry: poly}}}), "ignore objects with strictCRS within"); assert.eq(0, coll.count({geo: {$geoIntersects: {$geometry: poly}}}), "ignore objects with strictCRS intersects"); @@ -162,9 +149,8 @@ coll.update({}, {$unset: {"geo.crs": ""}}, {multi: true}); var totalDocs = coll.count(); assert.eq(totalDocs, coll.count({geo: {$geoWithin: {$geometry: poly}}}), "no strictCRS within"); -assert.eq(totalDocs, - coll.count({geo: {$geoIntersects: {$geometry: poly}}}), - "no strictCRS intersects"); +assert.eq( + totalDocs, coll.count({geo: {$geoIntersects: {$geometry: poly}}}), "no strictCRS intersects"); // Clear collection coll.remove({}); diff --git a/jstests/core/geo_borders.js b/jstests/core/geo_borders.js index f0a47339591..f8a94d997dd 100644 --- a/jstests/core/geo_borders.js +++ b/jstests/core/geo_borders.js @@ -33,81 +33,75 @@ assert.commandWorked(res); // ************ // If the bounds are bigger than the box itself, just clip at the borders -assert.eq(numItems, - t.find({ - loc: { - $within: { - $box: [ - [overallMin - 2 * epsilon, overallMin - 2 * epsilon], - [overallMax + 2 * epsilon, overallMax + 2 * epsilon] - ] - } - } - }).count()); +assert.eq(numItems, t.find({ + loc: { + $within: { + $box: [ + [overallMin - 2 * epsilon, overallMin - 2 * epsilon], + [overallMax + 2 * epsilon, overallMax + 2 * epsilon] + ] + } + } + }).count()); // Check this works also for bounds where only a single dimension is off-bounds -assert.eq(numItems - 5, - t.find({ - loc: { - $within: { - $box: [ - [overallMin - 2 * epsilon, overallMin - 0.5 * epsilon], - [overallMax - epsilon, overallMax - epsilon] - ] - } - } - }).count()); +assert.eq(numItems - 5, t.find({ + loc: { + $within: { + $box: [ + [overallMin - 2 * epsilon, overallMin - 0.5 * epsilon], + [overallMax - epsilon, overallMax - epsilon] + ] + } + } + }).count()); // Make sure we can get at least close to the bounds of the index -assert.eq(numItems, - t.find({ - loc: { - $within: { - $box: [ - [overallMin - epsilon / 2, overallMin - epsilon / 2], - [overallMax + epsilon / 2, overallMax + epsilon / 2] - ] - } - } - }).count()); +assert.eq(numItems, t.find({ + loc: { + $within: { + $box: [ + [overallMin - epsilon / 2, overallMin - epsilon / 2], + [overallMax + epsilon / 2, overallMax + epsilon / 2] + ] + } + } + }).count()); // Make sure we can get at least close to the bounds of the index -assert.eq(numItems, - t.find({ - loc: { - $within: { - $box: [ - [overallMax + epsilon / 2, overallMax + epsilon / 2], - [overallMin - epsilon / 2, overallMin - epsilon / 2] - ] - } - } - }).count()); +assert.eq(numItems, t.find({ + loc: { + $within: { + $box: [ + [overallMax + epsilon / 2, overallMax + epsilon / 2], + [overallMin - epsilon / 2, overallMin - epsilon / 2] + ] + } + } + }).count()); // Check that swapping min/max has good behavior -assert.eq(numItems, - t.find({ - loc: { - $within: { - $box: [ - [overallMax + epsilon / 2, overallMax + epsilon / 2], - [overallMin - epsilon / 2, overallMin - epsilon / 2] - ] - } - } - }).count()); - -assert.eq(numItems, - t.find({ - loc: { - $within: { - $box: [ - [overallMax + epsilon / 2, overallMin - epsilon / 2], - [overallMin - epsilon / 2, overallMax + epsilon / 2] - ] - } - } - }).count()); +assert.eq(numItems, t.find({ + loc: { + $within: { + $box: [ + [overallMax + epsilon / 2, overallMax + epsilon / 2], + [overallMin - epsilon / 2, overallMin - epsilon / 2] + ] + } + } + }).count()); + +assert.eq(numItems, t.find({ + loc: { + $within: { + $box: [ + [overallMax + epsilon / 2, overallMin - epsilon / 2], + [overallMin - epsilon / 2, overallMax + epsilon / 2] + ] + } + } + }).count()); // ************** // Circle tests @@ -206,6 +200,6 @@ assert.commandWorked(db.runCommand({geoNear: "borders", near: onBounds})); // Make sure we can get all nearby points within one step (4 points in top // corner) -assert.eq(4, - db.runCommand({geoNear: "borders", near: offCenter, maxDistance: step * 1.5}) - .results.length); +assert.eq( + 4, + db.runCommand({geoNear: "borders", near: offCenter, maxDistance: step * 1.5}).results.length); diff --git a/jstests/core/geo_box1.js b/jstests/core/geo_box1.js index 45e9aab9118..b1949063568 100644 --- a/jstests/core/geo_box1.js +++ b/jstests/core/geo_box1.js @@ -5,25 +5,25 @@ t.drop(); num = 0; for (x = 0; x <= 20; x++) { for (y = 0; y <= 20; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); } } t.ensureIndex({loc: "2d"}); -searches = [[[1, 2], [4, 5]], [[1, 1], [2, 2]], [[0, 2], [4, 5]], [[1, 1], [2, 8]], ]; +searches = [ + [[1, 2], [4, 5]], + [[1, 1], [2, 2]], + [[0, 2], [4, 5]], + [[1, 1], [2, 8]], +]; for (i = 0; i < searches.length; i++) { b = searches[i]; // printjson( b ); - q = { - loc: {$within: {$box: b}} - }; + q = {loc: {$within: {$box: b}}}; numWanetd = (1 + b[1][0] - b[0][0]) * (1 + b[1][1] - b[0][1]); assert.eq(numWanetd, t.find(q).itcount(), "itcount: " + tojson(q)); printjson(t.find(q).explain()); diff --git a/jstests/core/geo_box1_noindex.js b/jstests/core/geo_box1_noindex.js index 36e932105a6..a953149c59f 100644 --- a/jstests/core/geo_box1_noindex.js +++ b/jstests/core/geo_box1_noindex.js @@ -5,21 +5,21 @@ t.drop(); num = 0; for (x = 0; x <= 20; x++) { for (y = 0; y <= 20; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); } } -searches = [[[1, 2], [4, 5]], [[1, 1], [2, 2]], [[0, 2], [4, 5]], [[1, 1], [2, 8]], ]; +searches = [ + [[1, 2], [4, 5]], + [[1, 1], [2, 2]], + [[0, 2], [4, 5]], + [[1, 1], [2, 8]], +]; for (i = 0; i < searches.length; i++) { b = searches[i]; - q = { - loc: {$within: {$box: b}} - }; + q = {loc: {$within: {$box: b}}}; numWanted = (1 + b[1][0] - b[0][0]) * (1 + b[1][1] - b[0][1]); assert.eq(numWanted, t.find(q).itcount(), "itcount: " + tojson(q)); printjson(t.find(q).explain()); diff --git a/jstests/core/geo_center_sphere1.js b/jstests/core/geo_center_sphere1.js index f3b39b552cd..1ee46b03486 100644 --- a/jstests/core/geo_center_sphere1.js +++ b/jstests/core/geo_center_sphere1.js @@ -27,10 +27,7 @@ function test(index) { var bulk = t.initializeUnorderedBulkOp(); for (x = -179; x <= 179; x += skip) { for (y = -89; y <= 89; y += skip) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; bulk.insert(o); for (i = 0; i < searches.length; i++) { if (Geo.sphereDistance([x, y], searches[i][0]) <= searches[i][1]) @@ -48,9 +45,7 @@ function test(index) { for (i = 0; i < searches.length; i++) { print('------------'); print(tojson(searches[i]) + "\t" + correct[i].length); - q = { - loc: {$within: {$centerSphere: searches[i]}} - }; + q = {loc: {$within: {$centerSphere: searches[i]}}}; // correct[i].forEach( printjson ) // printjson( q ); diff --git a/jstests/core/geo_center_sphere2.js b/jstests/core/geo_center_sphere2.js index f3dc465e350..79c69de1ab4 100644 --- a/jstests/core/geo_center_sphere2.js +++ b/jstests/core/geo_center_sphere2.js @@ -131,12 +131,12 @@ for (var test = 0; test < numTests; test++) { // geoNear results = db.runCommand({ - geoNear: "sphere", - near: startPoint, - maxDistance: radius, - num: 2 * pointsIn, - spherical: true - }).results; + geoNear: "sphere", + near: startPoint, + maxDistance: radius, + num: 2 * pointsIn, + spherical: true + }).results; /* printjson( results ); diff --git a/jstests/core/geo_circle1.js b/jstests/core/geo_circle1.js index a679a408b32..c5b6841b9a8 100644 --- a/jstests/core/geo_circle1.js +++ b/jstests/core/geo_circle1.js @@ -2,7 +2,12 @@ t = db.geo_circle1; t.drop(); -searches = [[[5, 5], 3], [[5, 5], 1], [[5, 5], 5], [[0, 5], 5], ]; +searches = [ + [[5, 5], 3], + [[5, 5], 1], + [[5, 5], 5], + [[0, 5], 5], +]; correct = searches.map(function(z) { return []; }); @@ -11,10 +16,7 @@ num = 0; for (x = 0; x <= 20; x++) { for (y = 0; y <= 20; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); for (i = 0; i < searches.length; i++) if (Geo.distance([x, y], searches[i][0]) <= searches[i][1]) @@ -26,9 +28,7 @@ t.ensureIndex({loc: "2d"}); for (i = 0; i < searches.length; i++) { // print( tojson( searches[i] ) + "\t" + correct[i].length ) - q = { - loc: {$within: {$center: searches[i]}} - }; + q = {loc: {$within: {$center: searches[i]}}}; // correct[i].forEach( printjson ) // printjson( q ); diff --git a/jstests/core/geo_circle1_noindex.js b/jstests/core/geo_circle1_noindex.js index 872883dbf74..6c3135855a5 100644 --- a/jstests/core/geo_circle1_noindex.js +++ b/jstests/core/geo_circle1_noindex.js @@ -2,7 +2,12 @@ t = db.geo_circle1_noindex; t.drop(); -searches = [[[5, 5], 3], [[5, 5], 1], [[5, 5], 5], [[0, 5], 5], ]; +searches = [ + [[5, 5], 3], + [[5, 5], 1], + [[5, 5], 5], + [[0, 5], 5], +]; correct = searches.map(function(z) { return []; }); @@ -11,10 +16,7 @@ num = 0; for (x = 0; x <= 20; x++) { for (y = 0; y <= 20; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); for (i = 0; i < searches.length; i++) if (Geo.distance([x, y], searches[i][0]) <= searches[i][1]) @@ -23,9 +25,7 @@ for (x = 0; x <= 20; x++) { } for (i = 0; i < searches.length; i++) { - q = { - loc: {$within: {$center: searches[i]}} - }; + q = {loc: {$within: {$center: searches[i]}}}; assert.eq(correct[i].length, t.find(q).itcount(), "itcount : " + tojson(searches[i])); assert.eq(correct[i].length, t.find(q).count(), "count : " + tojson(searches[i])); } diff --git a/jstests/core/geo_distinct.js b/jstests/core/geo_distinct.js index 705bf1cc7ce..33ea7dd3461 100644 --- a/jstests/core/geo_distinct.js +++ b/jstests/core/geo_distinct.js @@ -60,10 +60,7 @@ for (var i = 0; i < 50; ++i) { coll.insert({zone: 4, loc: {type: 'Point', coordinates: [10, 10]}}); coll.insert({zone: 5, loc: {type: 'Point', coordinates: [20, 20]}}); } -var originGeoJSON = { - type: 'Point', - coordinates: [0, 0] -}; +var originGeoJSON = {type: 'Point', coordinates: [0, 0]}; // Test distinct with $nearSphere query predicate. diff --git a/jstests/core/geo_fiddly_box.js b/jstests/core/geo_fiddly_box.js index f5cd3ddcc6b..4e33780112d 100644 --- a/jstests/core/geo_fiddly_box.js +++ b/jstests/core/geo_fiddly_box.js @@ -19,9 +19,8 @@ t.insert({"loc": [3, -1]}); // OK! print(t.count()); -assert.eq(7, - t.count({"loc": {"$within": {"$box": [[2, -2], [46, 2]]}}}), - "Not all locations found!"); +assert.eq( + 7, t.count({"loc": {"$within": {"$box": [[2, -2], [46, 2]]}}}), "Not all locations found!"); // Test normal lookup of a small square of points as a sanity check. diff --git a/jstests/core/geo_group.js b/jstests/core/geo_group.js index 9ee5a76b7ea..34ecc2c3a84 100644 --- a/jstests/core/geo_group.js +++ b/jstests/core/geo_group.js @@ -20,22 +20,18 @@ assert.eq(t.find({loc: {$near: [56, 8, 10]}}).count(), 81); // Test basic group that effectively does a count assert.eq(t.group({ reduce: function(obj, prev) { - prev.sums = { - count: prev.sums.count + 1 - }; + prev.sums = {count: prev.sums.count + 1}; }, initial: {sums: {count: 0}} }), - [{"sums": {"count": 10000}}]); + [{"sums": {"count": 10000}}]); // Test basic group + $near that does a count assert.eq(t.group({ reduce: function(obj, prev) { - prev.sums = { - count: prev.sums.count + 1 - }; + prev.sums = {count: prev.sums.count + 1}; }, initial: {sums: {count: 0}}, cond: {loc: {$near: [56, 8, 10]}} }), - [{"sums": {"count": 81}}]); + [{"sums": {"count": 81}}]); diff --git a/jstests/core/geo_haystack1.js b/jstests/core/geo_haystack1.js index 5abb166a6f9..97e746ccdfa 100644 --- a/jstests/core/geo_haystack1.js +++ b/jstests/core/geo_haystack1.js @@ -16,13 +16,12 @@ function distanceTotal(a, arr, f) { return total; } -queries = [{near: [7, 8], maxDistance: 3, search: {z: 3}}, ]; +queries = [ + {near: [7, 8], maxDistance: 3, search: {z: 3}}, +]; answers = queries.map(function() { - return { - totalDistance: 0, - results: [] - }; + return {totalDistance: 0, results: []}; }); n = 0; diff --git a/jstests/core/geo_haystack2.js b/jstests/core/geo_haystack2.js index cb684239a63..3420feeed1c 100644 --- a/jstests/core/geo_haystack2.js +++ b/jstests/core/geo_haystack2.js @@ -16,13 +16,12 @@ function distanceTotal(a, arr, f) { return total; } -queries = [{near: [7, 8], maxDistance: 3, search: {z: 3}}, ]; +queries = [ + {near: [7, 8], maxDistance: 3, search: {z: 3}}, +]; answers = queries.map(function() { - return { - totalDistance: 0, - results: [] - }; + return {totalDistance: 0, results: []}; }); n = 0; diff --git a/jstests/core/geo_invalid_polygon.js b/jstests/core/geo_invalid_polygon.js index c3d244a504f..0eab7ca5406 100644 --- a/jstests/core/geo_invalid_polygon.js +++ b/jstests/core/geo_invalid_polygon.js @@ -5,10 +5,7 @@ t.drop(); // Self-intersecting polygon, triggers // "Exterior shell of polygon is invalid". -var geometry = { - type: "Polygon", - coordinates: [[[0, 0], [0, 1], [1, 1], [-2, -1], [0, 0]]] -}; +var geometry = {type: "Polygon", coordinates: [[[0, 0], [0, 1], [1, 1], [-2, -1], [0, 0]]]}; t.insert({_id: 42, geometry: geometry}); var err = t.createIndex({geometry: '2dsphere'}); diff --git a/jstests/core/geo_mapreduce.js b/jstests/core/geo_mapreduce.js index e15a4911763..ebea034d00c 100644 --- a/jstests/core/geo_mapreduce.js +++ b/jstests/core/geo_mapreduce.js @@ -32,9 +32,7 @@ r = function(key, values) { for (var i = 0; i < values.length; i++) { total += values[i].apples; } - return { - "apples": total - }; + return {"apples": total}; }; // mapreduce without geo query works fine diff --git a/jstests/core/geo_mapreduce2.js b/jstests/core/geo_mapreduce2.js index d71eb8ef216..679b6474cc9 100644 --- a/jstests/core/geo_mapreduce2.js +++ b/jstests/core/geo_mapreduce2.js @@ -21,19 +21,15 @@ r = function(key, values) { total += values[i].count; } - return { - count: total - }; + return {count: total}; }; try { - coll.mapReduce(m, - r, - { - out: coll.getName() + "_mr", - sort: {_id: 1}, - query: {'location': {$within: {$centerSphere: [[10, 20], 0.01]}}} - }); + coll.mapReduce(m, r, { + out: coll.getName() + "_mr", + sort: {_id: 1}, + query: {'location': {$within: {$centerSphere: [[10, 20], 0.01]}}} + }); } catch (e) { // This should occur, since we can't in-mem sort for mreduce diff --git a/jstests/core/geo_mindistance.js b/jstests/core/geo_mindistance.js index 6a2329bc524..4bbb77db9bf 100644 --- a/jstests/core/geo_mindistance.js +++ b/jstests/core/geo_mindistance.js @@ -47,12 +47,7 @@ for (var x = 0; x <= 10; x += 1) { /* $minDistance is supported for 2dsphere index only, not 2d or geoHaystack. */ t.ensureIndex({loc: "2dsphere"}); -var n_docs = t.count(), geoJSONPoint = - { - type: 'Point', - coordinates: [0, 0] - }, - legacyPoint = [0, 0]; +var n_docs = t.count(), geoJSONPoint = {type: 'Point', coordinates: [0, 0]}, legacyPoint = [0, 0]; // // Test $near with GeoJSON point (required for $near with 2dsphere index). @@ -67,9 +62,10 @@ assert.eq(n_docs - n_docs_within(1400), "Expected " + (n_docs - n_docs_within(1400)) + " points $near (0, 0) with $minDistance 1400 km, got " + n_min1400_count); -var n_bw500_and_1000_count = t.find({ - loc: {$near: {$geometry: geoJSONPoint, $minDistance: 500 * km, $maxDistance: 1000 * km}} -}).count(); +var n_bw500_and_1000_count = + t.find({ + loc: {$near: {$geometry: geoJSONPoint, $minDistance: 500 * km, $maxDistance: 1000 * km}} + }).count(); assert.eq(n_docs_within(1000) - n_docs_within(500), n_bw500_and_1000_count, @@ -92,12 +88,12 @@ assert.eq(n_docs - n_docs_within(1400), " points $nearSphere (0, 0) with $minDistance 1400 km, got " + n_min1400_count); n_bw500_and_1000_count = t.find({ - loc: { - $nearSphere: legacyPoint, - $minDistance: metersToRadians(500 * km), - $maxDistance: metersToRadians(1000 * km) - } -}).count(); + loc: { + $nearSphere: legacyPoint, + $minDistance: metersToRadians(500 * km), + $maxDistance: metersToRadians(1000 * km) + } + }).count(); assert.eq(n_docs_within(1000) - n_docs_within(500), n_bw500_and_1000_count, @@ -118,8 +114,9 @@ assert.eq(n_docs - n_docs_within(1400), " points $nearSphere (0, 0) with $minDistance 1400 km, got " + n_min1400_count); n_bw500_and_1000_count = - t.find({loc: {$nearSphere: geoJSONPoint, $minDistance: 500 * km, $maxDistance: 1000 * km}}) - .count(); + t.find({ + loc: {$nearSphere: geoJSONPoint, $minDistance: 500 * km, $maxDistance: 1000 * km} + }).count(); assert.eq(n_docs_within(1000) - n_docs_within(500), n_bw500_and_1000_count, diff --git a/jstests/core/geo_mindistance_boundaries.js b/jstests/core/geo_mindistance_boundaries.js index 6cbae8015e9..7e97732dfd1 100644 --- a/jstests/core/geo_mindistance_boundaries.js +++ b/jstests/core/geo_mindistance_boundaries.js @@ -12,11 +12,7 @@ t.ensureIndex({loc: "2dsphere"}); // Useful constants. // -var km = 1000, earthRadiusMeters = 6378.1 * km, geoJSONPoint = - { - type: 'Point', - coordinates: [0, 0] - }, +var km = 1000, earthRadiusMeters = 6378.1 * km, geoJSONPoint = {type: 'Point', coordinates: [0, 0]}, // One degree of longitude at the equator, about 111 km. degreeInMeters = 2 * Math.PI * earthRadiusMeters / 360, metersEpsilon = Number.MIN_VALUE; @@ -43,33 +39,37 @@ assert.eq(1, assert.eq( 1, - t.find({loc: {$near: {$geometry: geoJSONPoint, $minDistance: degreeInMeters - metersEpsilon}}}) - .itcount(), + t.find({ + loc: {$near: {$geometry: geoJSONPoint, $minDistance: degreeInMeters - metersEpsilon}} + }).itcount(), "Expected to find (0, 1) within $minDistance (1 degree - epsilon) from origin"); assert.eq( 0, - t.find({loc: {$near: {$geometry: geoJSONPoint, $minDistance: degreeInMeters + metersEpsilon}}}) - .itcount(), + t.find({ + loc: {$near: {$geometry: geoJSONPoint, $minDistance: degreeInMeters + metersEpsilon}} + }).itcount(), "Expected *not* to find (0, 1) within $minDistance (1 degree + epsilon) from origin"); // // Test boundary conditions for $nearSphere and GeoJSON, in meters. // -assert.eq(1, - t.find({loc: {$nearSphere: {$geometry: geoJSONPoint, $minDistance: degreeInMeters}}}) - .itcount(), - "Expected to find (0, 1) within $minDistance 1 degree from origin"); +assert.eq( + 1, + t.find({loc: {$nearSphere: {$geometry: geoJSONPoint, $minDistance: degreeInMeters}}}).itcount(), + "Expected to find (0, 1) within $minDistance 1 degree from origin"); assert.eq(1, - t.find({loc: {$nearSphere: geoJSONPoint, $minDistance: degreeInMeters - metersEpsilon}}) - .itcount(), + t.find({ + loc: {$nearSphere: geoJSONPoint, $minDistance: degreeInMeters - metersEpsilon} + }).itcount(), "Expected to find (0, 1) within $minDistance (1 degree - epsilon) from origin"); assert.eq(0, - t.find({loc: {$nearSphere: geoJSONPoint, $minDistance: degreeInMeters + metersEpsilon}}) - .itcount(), + t.find({ + loc: {$nearSphere: geoJSONPoint, $minDistance: degreeInMeters + metersEpsilon} + }).itcount(), "Expected *not* to find (0, 1) within $minDistance (1 degree + epsilon) from origin"); // @@ -90,11 +90,13 @@ assert.eq(1, "Expected to find (0, 1) within $minDistance 1 degree from origin"); assert.eq(1, - t.find({loc: {$nearSphere: legacyPoint, $minDistance: degreeInRadians - radiansEpsilon}}) - .itcount(), + t.find({ + loc: {$nearSphere: legacyPoint, $minDistance: degreeInRadians - radiansEpsilon} + }).itcount(), "Expected to find (0, 1) within $minDistance (1 degree - epsilon) from origin"); assert.eq(0, - t.find({loc: {$nearSphere: legacyPoint, $minDistance: degreeInRadians + radiansEpsilon}}) - .itcount(), + t.find({ + loc: {$nearSphere: legacyPoint, $minDistance: degreeInRadians + radiansEpsilon} + }).itcount(), "Expected *not* to find (0, 1) within $minDistance (1 degree + epsilon) from origin"); diff --git a/jstests/core/geo_operator_crs.js b/jstests/core/geo_operator_crs.js index b9e242309dc..13353f2262d 100644 --- a/jstests/core/geo_operator_crs.js +++ b/jstests/core/geo_operator_crs.js @@ -12,15 +12,9 @@ coll.drop(); assert.commandWorked(coll.ensureIndex({geo: "2dsphere"})); var legacyZeroPt = [0, 0]; -var jsonZeroPt = { - type: "Point", - coordinates: [0, 0] -}; +var jsonZeroPt = {type: "Point", coordinates: [0, 0]}; var legacy90Pt = [90, 0]; -var json90Pt = { - type: "Point", - coordinates: [90, 0] -}; +var json90Pt = {type: "Point", coordinates: [90, 0]}; assert.writeOK(coll.insert({geo: json90Pt})); diff --git a/jstests/core/geo_or.js b/jstests/core/geo_or.js index 20eb7b7dce1..341ce32d397 100644 --- a/jstests/core/geo_or.js +++ b/jstests/core/geo_or.js @@ -30,54 +30,54 @@ assert.throws(function() { assert.eq(2, t.find({ - $or: [ - {loc: {$geoWithin: {$centerSphere: [p, 10]}}}, - {loc: {$geoWithin: {$centerSphere: [p, 10]}}} - ] - }).itcount(), + $or: [ + {loc: {$geoWithin: {$centerSphere: [p, 10]}}}, + {loc: {$geoWithin: {$centerSphere: [p, 10]}}} + ] + }).itcount(), 'multiple $geoWithin clauses not supported by $or. index type: ' + indexname); +assert.eq( + 2, + t.find({ + $or: [ + {loc: {$geoIntersects: {$geometry: {type: 'LineString', coordinates: [p, q]}}}}, + { + loc: { + $geoIntersects: + {$geometry: {type: 'LineString', coordinates: [[0, 0], [1, 1]]}} + } + } + ] + }).itcount(), + 'multiple $geoIntersects LineString clauses not supported by $or. index type: ' + indexname); assert.eq(2, t.find({ - $or: [ - {loc: {$geoIntersects: {$geometry: {type: 'LineString', coordinates: [p, q]}}}}, - { - loc: { - $geoIntersects: - {$geometry: {type: 'LineString', coordinates: [[0, 0], [1, 1]]}} - } - } - ] - }).itcount(), - 'multiple $geoIntersects LineString clauses not supported by $or. index type: ' + - indexname); -assert.eq(2, - t.find({ - $or: [ - {loc: {$geoIntersects: {$geometry: {type: 'Point', coordinates: p}}}}, - {loc: {$geoIntersects: {$geometry: {type: 'Point', coordinates: q}}}} - ] - }).itcount(), + $or: [ + {loc: {$geoIntersects: {$geometry: {type: 'Point', coordinates: p}}}}, + {loc: {$geoIntersects: {$geometry: {type: 'Point', coordinates: q}}}} + ] + }).itcount(), 'multiple $geoIntersects Point clauses not supported by $or. index type: ' + indexname); assert.eq( 2, t.find({ - $or: [ - { - loc: { - $geoIntersects: - {$geometry: {type: 'Polygon', coordinates: [[[0, 0], p, q, [0, 0]]]}} - } - }, - { - loc: { - $geoIntersects: { - $geometry: - {type: 'Polygon', coordinates: [[[0, 0], [1, 1], [0, 1], [0, 0]]]} - } - } - } - ] - }).itcount(), + $or: [ + { + loc: { + $geoIntersects: + {$geometry: {type: 'Polygon', coordinates: [[[0, 0], p, q, [0, 0]]]}} + } + }, + { + loc: { + $geoIntersects: { + $geometry: + {type: 'Polygon', coordinates: [[[0, 0], [1, 1], [0, 1], [0, 0]]]} + } + } + } + ] + }).itcount(), 'multiple $geoIntersects Polygon clauses not supported by $or. index type: ' + indexname); t.dropIndexes(); @@ -88,9 +88,9 @@ t.ensureIndex({loc: indexname}); assert.eq(2, t.find({ - $or: [ - {loc: {$geoWithin: {$centerSphere: [p, 10]}}}, - {loc: {$geoWithin: {$centerSphere: [p, 10]}}} - ] - }).itcount(), + $or: [ + {loc: {$geoWithin: {$centerSphere: [p, 10]}}}, + {loc: {$geoWithin: {$centerSphere: [p, 10]}}} + ] + }).itcount(), 'multiple $geoWithin clauses not supported by $or. index type: ' + indexname); diff --git a/jstests/core/geo_poly_edge.js b/jstests/core/geo_poly_edge.js index 380fe533861..a8239cde0af 100644 --- a/jstests/core/geo_poly_edge.js +++ b/jstests/core/geo_poly_edge.js @@ -17,6 +17,6 @@ assert.eq(coll.find({loc: {$within: {$polygon: [[10, 10], [10, 10], [10, 10]]}}} coll.insert({loc: [179, 0]}); coll.insert({loc: [0, 179]}); -assert.eq(coll.find({loc: {$within: {$polygon: [[0, 0], [1000, 0], [1000, 1000], [0, 1000]]}}}) - .itcount(), - 3); +assert.eq( + coll.find({loc: {$within: {$polygon: [[0, 0], [1000, 0], [1000, 1000], [0, 1000]]}}}).itcount(), + 3); diff --git a/jstests/core/geo_polygon1.js b/jstests/core/geo_polygon1.js index d1dbf0c19dc..45f0eb71d64 100644 --- a/jstests/core/geo_polygon1.js +++ b/jstests/core/geo_polygon1.js @@ -8,10 +8,7 @@ t.drop(); num = 0; for (x = 1; x < 9; x++) { for (y = 1; y < 9; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); } } @@ -29,15 +26,14 @@ assert.eq(num, t.find({loc: {"$within": {"$polygon": boxBounds}}}).count(), "Bou // Make sure we can add object-based polygons assert.eq( - num, - t.find({loc: {$within: {$polygon: {a: [-10, -10], b: [-10, 10], c: [10, 10], d: [10, -10]}}}}) - .count()); + num, t.find({ + loc: {$within: {$polygon: {a: [-10, -10], b: [-10, 10], c: [10, 10], d: [10, -10]}}} + }).count()); // Look in a box much bigger than the one we have data in boxBounds = [[-100, -100], [-100, 100], [100, 100], [100, -100]]; -assert.eq(num, - t.find({loc: {"$within": {"$polygon": boxBounds}}}).count(), - "Big Bounding Box Test"); +assert.eq( + num, t.find({loc: {"$within": {"$polygon": boxBounds}}}).count(), "Big Bounding Box Test"); t.drop(); diff --git a/jstests/core/geo_polygon1_noindex.js b/jstests/core/geo_polygon1_noindex.js index 22f90e7157c..e5aabb5043d 100644 --- a/jstests/core/geo_polygon1_noindex.js +++ b/jstests/core/geo_polygon1_noindex.js @@ -6,10 +6,7 @@ t.drop(); num = 0; for (x = 1; x < 9; x++) { for (y = 1; y < 9; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); } } @@ -25,15 +22,14 @@ assert.eq(num, t.find({loc: {"$within": {"$polygon": boxBounds}}}).count(), "Bou // Make sure we can add object-based polygons assert.eq( - num, - t.find({loc: {$within: {$polygon: {a: [-10, -10], b: [-10, 10], c: [10, 10], d: [10, -10]}}}}) - .count()); + num, t.find({ + loc: {$within: {$polygon: {a: [-10, -10], b: [-10, 10], c: [10, 10], d: [10, -10]}}} + }).count()); // Look in a box much bigger than the one we have data in boxBounds = [[-100, -100], [-100, 100], [100, 100], [100, -100]]; -assert.eq(num, - t.find({loc: {"$within": {"$polygon": boxBounds}}}).count(), - "Big Bounding Box Test"); +assert.eq( + num, t.find({loc: {"$within": {"$polygon": boxBounds}}}).count(), "Big Bounding Box Test"); t.drop(); diff --git a/jstests/core/geo_polygon3.js b/jstests/core/geo_polygon3.js index ed8f040fa8d..1f81e70adfa 100644 --- a/jstests/core/geo_polygon3.js +++ b/jstests/core/geo_polygon3.js @@ -11,10 +11,7 @@ for (var n = 0; n < numTests; n++) { num = 0; for (x = 1; x < 9; x++) { for (y = 1; y < 9; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); } } diff --git a/jstests/core/geo_s2cursorlimitskip.js b/jstests/core/geo_s2cursorlimitskip.js index 25ae81beb2d..427fbf8fe29 100644 --- a/jstests/core/geo_s2cursorlimitskip.js +++ b/jstests/core/geo_s2cursorlimitskip.js @@ -23,9 +23,7 @@ function insertRandomPoints(num, minDist, maxDist) { for (var i = 0; i < num; i++) { var lat = sign() * (minDist + random() * (maxDist - minDist)); var lng = sign() * (minDist + random() * (maxDist - minDist)); - var point = { - geo: {type: "Point", coordinates: [lng, lat]} - }; + var point = {geo: {type: "Point", coordinates: [lng, lat]}}; assert.writeOK(t.insert(point)); } } @@ -37,8 +35,9 @@ var batchSize = 4; // Insert points between 0.01 and 1.0 away. insertRandomPoints(totalPointCount, 0.01, 1.0); -var cursor = t.find({geo: {$geoNear: {$geometry: {type: "Point", coordinates: [0.0, 0.0]}}}}) - .batchSize(batchSize); +var cursor = t.find({ + geo: {$geoNear: {$geometry: {type: "Point", coordinates: [0.0, 0.0]}}} + }).batchSize(batchSize); assert.eq(cursor.count(), totalPointCount); // Disable profiling in order to drop the system.profile collection. @@ -48,8 +47,8 @@ testDB.setProfilingLevel(0); testDB.system.profile.drop(); // Create 4MB system.profile collection to prevent the 'getmore' operations from overwriting the // original query. -assert.commandWorked(testDB.createCollection("system.profile", - {capped: true, size: 4 * 1024 * 1024})); +assert.commandWorked( + testDB.createCollection("system.profile", {capped: true, size: 4 * 1024 * 1024})); testDB.setProfilingLevel(2); for (var j = 0; j < initialAdvance; j++) { @@ -81,14 +80,16 @@ assert(!cursor.hasNext()); var someLimit = 23; // Make sure limit does something. -cursor = t.find({geo: {$geoNear: {$geometry: {type: "Point", coordinates: [0.0, 0.0]}}}}) - .limit(someLimit); +cursor = t.find({ + geo: {$geoNear: {$geometry: {type: "Point", coordinates: [0.0, 0.0]}}} + }).limit(someLimit); // Count doesn't work here -- ignores limit/skip, so we use itcount. assert.eq(cursor.itcount(), someLimit); // Make sure skip works by skipping some stuff ourselves. var someSkip = 3; -cursor = t.find({geo: {$geoNear: {$geometry: {type: "Point", coordinates: [0.0, 0.0]}}}}) - .limit(someLimit + someSkip); +cursor = t.find({ + geo: {$geoNear: {$geometry: {type: "Point", coordinates: [0.0, 0.0]}}} + }).limit(someLimit + someSkip); for (var i = 0; i < someSkip; ++i) { cursor.next(); } diff --git a/jstests/core/geo_s2descindex.js b/jstests/core/geo_s2descindex.js index d6dca95213d..daf5531b31d 100644 --- a/jstests/core/geo_s2descindex.js +++ b/jstests/core/geo_s2descindex.js @@ -5,24 +5,14 @@ var coll = db.getCollection("twodspheredesc"); var descriptors = [["field1", -1], ["field2", -1], ["coordinates", "2dsphere"]]; -var docA = { - field1: "a", - field2: 1, - coordinates: [-118.2400013, 34.073893] -}; -var docB = { - field1: "b", - field2: 1, - coordinates: [-118.2400012, 34.073894] -}; +var docA = {field1: "a", field2: 1, coordinates: [-118.2400013, 34.073893]}; +var docB = {field1: "b", field2: 1, coordinates: [-118.2400012, 34.073894]}; // Try both regular and near index cursors var query = { coordinates: {$geoWithin: {$centerSphere: [[-118.240013, 34.073893], 0.44915760491198753]}} }; -var queryNear = { - coordinates: {$geoNear: {"type": "Point", "coordinates": [0, 0]}} -}; +var queryNear = {coordinates: {$geoNear: {"type": "Point", "coordinates": [0, 0]}}}; // // The idea here is we try "2dsphere" indexes in combination with descending diff --git a/jstests/core/geo_s2disjoint_holes.js b/jstests/core/geo_s2disjoint_holes.js index a3988e9a614..f7731b416e4 100644 --- a/jstests/core/geo_s2disjoint_holes.js +++ b/jstests/core/geo_s2disjoint_holes.js @@ -8,18 +8,14 @@ // http://geojson.org/geojson-spec.html#polygon // -var t = db.geo_s2disjoint_holes, coordinates = [ - // One square. - [[9, 9], [9, 11], [11, 11], [11, 9], [9, 9]], - // Another disjoint square. - [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]] -], - poly = - { - type: 'Polygon', - coordinates: coordinates - }, - multiPoly = { +var t = db.geo_s2disjoint_holes, coordinates = + [ + // One square. + [[9, 9], [9, 11], [11, 11], [11, 9], [9, 9]], + // Another disjoint square. + [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]] + ], + poly = {type: 'Polygon', coordinates: coordinates}, multiPoly = { type: 'MultiPolygon', // Multi-polygon's coordinates are wrapped in one more array. coordinates: [coordinates] diff --git a/jstests/core/geo_s2dupe_points.js b/jstests/core/geo_s2dupe_points.js index 63e4369d2fa..406a7b1ff4c 100644 --- a/jstests/core/geo_s2dupe_points.js +++ b/jstests/core/geo_s2dupe_points.js @@ -28,10 +28,7 @@ var lineWithDupes = { _id: "line", geo: {type: "LineString", coordinates: [[40, 5], [40, 5], [40, 5], [41, 6], [41, 6]]} }; -var lineWithoutDupes = { - type: "LineString", - coordinates: [[40, 5], [41, 6]] -}; +var lineWithoutDupes = {type: "LineString", coordinates: [[40, 5], [41, 6]]}; // Polygon var polygonWithDupes = { diff --git a/jstests/core/geo_s2explain.js b/jstests/core/geo_s2explain.js index c8d32e00379..97f45e89a68 100644 --- a/jstests/core/geo_s2explain.js +++ b/jstests/core/geo_s2explain.js @@ -4,12 +4,8 @@ var t = db.jstests_geo_s2explain; t.drop(); -var point1 = { - loc: {type: "Point", coordinates: [10, 10]} -}; -var point2 = { - loc: {type: "Point", coordinates: [10.001, 10]} -}; +var point1 = {loc: {type: "Point", coordinates: [10, 10]}}; +var point2 = {loc: {type: "Point", coordinates: [10.001, 10]}}; assert.writeOK(t.insert([point1, point2])); assert.commandWorked(t.ensureIndex({loc: "2dsphere"})); diff --git a/jstests/core/geo_s2holesameasshell.js b/jstests/core/geo_s2holesameasshell.js index 29f00b88f7a..5407fe45c26 100644 --- a/jstests/core/geo_s2holesameasshell.js +++ b/jstests/core/geo_s2holesameasshell.js @@ -3,18 +3,9 @@ var t = db.geo_s2holessameasshell; t.drop(); t.ensureIndex({geo: "2dsphere"}); -var centerPoint = { - "type": "Point", - "coordinates": [0.5, 0.5] -}; -var edgePoint = { - "type": "Point", - "coordinates": [0, 0.5] -}; -var cornerPoint = { - "type": "Point", - "coordinates": [0, 0] -}; +var centerPoint = {"type": "Point", "coordinates": [0.5, 0.5]}; +var edgePoint = {"type": "Point", "coordinates": [0, 0.5]}; +var cornerPoint = {"type": "Point", "coordinates": [0, 0]}; // Various "edge" cases. None of them should be returned by the non-polygon // polygon below. diff --git a/jstests/core/geo_s2index.js b/jstests/core/geo_s2index.js index cc25b4fabfe..99c3852aae9 100644 --- a/jstests/core/geo_s2index.js +++ b/jstests/core/geo_s2index.js @@ -89,10 +89,12 @@ assert.throws(function() { return t.count({loc: {$foo: [0, 0]}}); }); assert.throws(function() { - return t.find({ - "nonGeo": "pointA", - "geo": {"$geoIntersects": {"$geometry": somepoly}, "$near": {"$geometry": somepoly}} - }).count(); + return t + .find({ + "nonGeo": "pointA", + "geo": {"$geoIntersects": {"$geometry": somepoly}, "$near": {"$geometry": somepoly}} + }) + .count(); }); // If we specify a datum, it has to be valid (WGS84). diff --git a/jstests/core/geo_s2indexversion1.js b/jstests/core/geo_s2indexversion1.js index 49aa80dbbca..4fa58bb589f 100644 --- a/jstests/core/geo_s2indexversion1.js +++ b/jstests/core/geo_s2indexversion1.js @@ -106,15 +106,9 @@ coll.drop(); // Test compatibility of various GeoJSON objects with both 2dsphere index versions. // -var pointDoc = { - geo: {type: "Point", coordinates: [40, 5]} -}; -var lineStringDoc = { - geo: {type: "LineString", coordinates: [[40, 5], [41, 6]]} -}; -var polygonDoc = { - geo: {type: "Polygon", coordinates: [[[0, 0], [3, 6], [6, 1], [0, 0]]]} -}; +var pointDoc = {geo: {type: "Point", coordinates: [40, 5]}}; +var lineStringDoc = {geo: {type: "LineString", coordinates: [[40, 5], [41, 6]]}}; +var polygonDoc = {geo: {type: "Polygon", coordinates: [[[0, 0], [3, 6], [6, 1], [0, 0]]]}}; var multiPointDoc = { geo: { type: "MultiPoint", @@ -144,12 +138,7 @@ var multiPolygonDoc = { [-73.9814, 40.7681], [-73.958, 40.8003] ]], - [[ - [-73.958, 40.8003], - [-73.9498, 40.7968], - [-73.9737, 40.7648], - [-73.958, 40.8003] - ]] + [[[-73.958, 40.8003], [-73.9498, 40.7968], [-73.9737, 40.7648], [-73.958, 40.8003]]] ] } }; diff --git a/jstests/core/geo_s2intersection.js b/jstests/core/geo_s2intersection.js index bf65c02c0c2..faf9304396c 100644 --- a/jstests/core/geo_s2intersection.js +++ b/jstests/core/geo_s2intersection.js @@ -10,10 +10,7 @@ var canonLine = { geo: {type: "LineString", coordinates: [[0.0, 0.0], [1.0, 0.0]]} }; -var canonPoint = { - name: 'canonPoint', - geo: {type: "Point", coordinates: [10.0, 10.0]} -}; +var canonPoint = {name: 'canonPoint', geo: {type: "Point", coordinates: [10.0, 10.0]}}; var canonPoly = { name: 'canonPoly', @@ -28,10 +25,7 @@ t.insert(canonPoint); t.insert(canonPoly); // Case 1: Basic sanity intersection. -var testLine = { - type: "LineString", - coordinates: [[0.5, 0.5], [0.5, -0.5]] -}; +var testLine = {type: "LineString", coordinates: [[0.5, 0.5], [0.5, -0.5]]}; var result = t.find({geo: {$geoIntersects: {$geometry: testLine}}}); assert.eq(result.count(), 1); @@ -127,10 +121,7 @@ assert.eq(result.count(), 1); assert.eq(result[0]['name'], 'canonPoint'); // Case 10: Sanity point non-intersection. -var testPoint = { - type: "Point", - coordinates: [12.0, 12.0] -}; +var testPoint = {type: "Point", coordinates: [12.0, 12.0]}; result = t.find({geo: {$geoIntersects: {$geometry: testPoint}}}); assert.eq(result.count(), 0); @@ -152,12 +143,8 @@ t.drop(); t.ensureIndex({a: "2dsphere"}); t.insert({a: {type: "Polygon", coordinates: [[[0, 0], [3, 6], [6, 0], [0, 0]]]}}); -var firstPoint = { - $geometry: {type: "Point", coordinates: [3.0, 1.0]} -}; -var secondPoint = { - $geometry: {type: "Point", coordinates: [4.0, 1.0]} -}; +var firstPoint = {$geometry: {type: "Point", coordinates: [3.0, 1.0]}}; +var secondPoint = {$geometry: {type: "Point", coordinates: [4.0, 1.0]}}; // First point should intersect with the polygon. result = t.find({a: {$geoIntersects: firstPoint}}); diff --git a/jstests/core/geo_s2multi.js b/jstests/core/geo_s2multi.js index 2cd6a3d73d7..8899c9d5561 100644 --- a/jstests/core/geo_s2multi.js +++ b/jstests/core/geo_s2multi.js @@ -28,39 +28,39 @@ multiPolygonA = { }; assert.writeOK(t.insert({geo: multiPolygonA})); -assert.eq(3, - t.find({geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [100, 0]}}}}) - .itcount()); +assert.eq(3, t.find({ + geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [100, 0]}}} + }).itcount()); assert.eq(3, t.find({ - geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [101.0, 1.0]}}} - }).itcount()); + geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [101.0, 1.0]}}} + }).itcount()); // Inside the hole in multiPolygonA assert.eq( - 0, - t.find({geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [100.21, 0.21]}}}}) - .itcount()); + 0, t.find({ + geo: {$geoIntersects: {$geometry: {"type": "Point", "coordinates": [100.21, 0.21]}}} + }).itcount()); // One point inside the hole, one out. assert.eq( 3, t.find({ - geo: { - $geoIntersects: - {$geometry: {"type": "MultiPoint", "coordinates": [[100, 0], [100.21, 0.21]]}} - } - }).itcount()); + geo: { + $geoIntersects: + {$geometry: {"type": "MultiPoint", "coordinates": [[100, 0], [100.21, 0.21]]}} + } + }).itcount()); assert.eq( 3, t.find({ - geo: { - $geoIntersects: { - $geometry: - {"type": "MultiPoint", "coordinates": [[100, 0], [100.21, 0.21], [101, 1]]} - } - } - }).itcount()); + geo: { + $geoIntersects: { + $geometry: + {"type": "MultiPoint", "coordinates": [[100, 0], [100.21, 0.21], [101, 1]]} + } + } + }).itcount()); // Polygon contains itself and the multipoint. assert.eq(2, t.find({geo: {$geoWithin: {$geometry: multiPolygonA}}}).itcount()); diff --git a/jstests/core/geo_s2near.js b/jstests/core/geo_s2near.js index 08bf5ab9081..f8bacf350b4 100644 --- a/jstests/core/geo_s2near.js +++ b/jstests/core/geo_s2near.js @@ -90,8 +90,8 @@ function testRadAndDegreesOK(distance) { assert.eq(resRadians.itcount(), resMeters.itcount()); // Also, geoNear should behave the same way. - resGNMeters = db.runCommand( - {geoNear: t.getName(), near: origin, maxDistance: distance, spherical: true}); + resGNMeters = + db.runCommand({geoNear: t.getName(), near: origin, maxDistance: distance, spherical: true}); resGNRadians = db.runCommand({ geoNear: t.getName(), near: [0, 0], diff --git a/jstests/core/geo_s2nearComplex.js b/jstests/core/geo_s2nearComplex.js index 0584c5e694a..bf9c76ffde4 100644 --- a/jstests/core/geo_s2nearComplex.js +++ b/jstests/core/geo_s2nearComplex.js @@ -11,15 +11,9 @@ var sin = Math.sin; var cos = Math.cos; var atan2 = Math.atan2; -var originGeo = { - type: "Point", - coordinates: [20.0, 20.0] -}; +var originGeo = {type: "Point", coordinates: [20.0, 20.0]}; // Center point for all tests. -var origin = { - name: "origin", - geo: originGeo -}; +var origin = {name: "origin", geo: originGeo}; /* * Convenience function for checking that coordinates match. threshold let's you @@ -163,9 +157,7 @@ function validateOrdering(query) { } } -var query = { - geo: {$geoNear: {$geometry: originGeo}} -}; +var query = {geo: {$geoNear: {$geometry: originGeo}}}; // Test a uniform distribution of 1000 points. uniformPoints(origin, 1000, 0.5, 1.5); diff --git a/jstests/core/geo_s2near_equator_opposite.js b/jstests/core/geo_s2near_equator_opposite.js index 13bbc776daa..754c27e523d 100644 --- a/jstests/core/geo_s2near_equator_opposite.js +++ b/jstests/core/geo_s2near_equator_opposite.js @@ -14,12 +14,16 @@ t.ensureIndex({loc: '2dsphere'}); // upper bound for half of earth's circumference in meters var dist = 40075000 / 2 + 1; -var nearSphereCount = t.find({ - loc: {$nearSphere: {$geometry: {type: 'Point', coordinates: [180, 0]}, $maxDistance: dist}} -}).itcount(); +var nearSphereCount = + t.find({ + loc: { + $nearSphere: {$geometry: {type: 'Point', coordinates: [180, 0]}, $maxDistance: dist} + } + }).itcount(); var nearCount = - t.find({loc: {$near: {$geometry: {type: 'Point', coordinates: [180, 0]}, $maxDistance: dist}}}) - .itcount(); + t.find({ + loc: {$near: {$geometry: {type: 'Point', coordinates: [180, 0]}, $maxDistance: dist}} + }).itcount(); var geoNearResult = db.runCommand( {geoNear: t.getName(), near: {type: 'Point', coordinates: [180, 0]}, spherical: true}); diff --git a/jstests/core/geo_s2nongeoarray.js b/jstests/core/geo_s2nongeoarray.js index 8684706d168..4b210f8f779 100644 --- a/jstests/core/geo_s2nongeoarray.js +++ b/jstests/core/geo_s2nongeoarray.js @@ -4,11 +4,7 @@ t = db.geo_s2nongeoarray; oldPoint = [40, 5]; -var data = { - geo: oldPoint, - nonGeo: [123, 456], - otherNonGeo: [{b: [1, 2]}, {b: [3, 4]}] -}; +var data = {geo: oldPoint, nonGeo: [123, 456], otherNonGeo: [{b: [1, 2]}, {b: [3, 4]}]}; t.drop(); assert.writeOK(t.insert(data)); diff --git a/jstests/core/geo_s2nonstring.js b/jstests/core/geo_s2nonstring.js index 43587f0c8e8..960f0c727a8 100644 --- a/jstests/core/geo_s2nonstring.js +++ b/jstests/core/geo_s2nonstring.js @@ -14,15 +14,13 @@ t.save({geo: {type: 'Point', coordinates: [0, 0]}, x: 'a'}); t.save({geo: {type: 'Point', coordinates: [0, 0]}}); // Expect 1 match, where x is 'a' -assert.eq(1, - t.count({ - geo: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}, $maxDistance: 20}}, - x: 'a' - })); +assert.eq(1, t.count({ + geo: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}, $maxDistance: 20}}, + x: 'a' +})); // Expect 1 match, where x matches null (missing matches null). -assert.eq(1, - t.count({ - geo: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}, $maxDistance: 20}}, - x: null - })); +assert.eq(1, t.count({ + geo: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}, $maxDistance: 20}}, + x: null +})); diff --git a/jstests/core/geo_s2oddshapes.js b/jstests/core/geo_s2oddshapes.js index 6f14533c928..4ae953696a0 100644 --- a/jstests/core/geo_s2oddshapes.js +++ b/jstests/core/geo_s2oddshapes.js @@ -5,10 +5,7 @@ var t = db.geo_s2oddshapes; t.drop(); t.ensureIndex({geo: "2dsphere"}); -var testPoint = { - name: "origin", - geo: {type: "Point", coordinates: [0.0, 0.0]} -}; +var testPoint = {name: "origin", geo: {type: "Point", coordinates: [0.0, 0.0]}}; var testHorizLine = { name: "horiz", @@ -60,10 +57,7 @@ assert.eq(result.itcount(), 3); t.drop(); t.ensureIndex({geo: "2dsphere"}); -var insidePoint = { - name: "inside", - geo: {type: "Point", name: "inside", coordinates: [100.0, 0.0]} -}; +var insidePoint = {name: "inside", geo: {type: "Point", name: "inside", coordinates: [100.0, 0.0]}}; var outsidePoint = { name: "inside", diff --git a/jstests/core/geo_s2polywithholes.js b/jstests/core/geo_s2polywithholes.js index 6ace711c718..80f7b0556c4 100644 --- a/jstests/core/geo_s2polywithholes.js +++ b/jstests/core/geo_s2polywithholes.js @@ -2,18 +2,9 @@ var t = db.geo_s2weirdpolys; t.drop(); t.ensureIndex({geo: "2dsphere"}); -var centerPoint = { - "type": "Point", - "coordinates": [0.5, 0.5] -}; -var edgePoint = { - "type": "Point", - "coordinates": [0, 0.5] -}; -var cornerPoint = { - "type": "Point", - "coordinates": [0, 0] -}; +var centerPoint = {"type": "Point", "coordinates": [0.5, 0.5]}; +var edgePoint = {"type": "Point", "coordinates": [0, 0.5]}; +var cornerPoint = {"type": "Point", "coordinates": [0, 0]}; t.insert({geo: centerPoint}); t.insert({geo: edgePoint}); diff --git a/jstests/core/geo_s2sparse.js b/jstests/core/geo_s2sparse.js index ab3363b5860..d31905b5a92 100644 --- a/jstests/core/geo_s2sparse.js +++ b/jstests/core/geo_s2sparse.js @@ -3,15 +3,9 @@ var coll = db.geo_s2sparse; -var point = { - type: "Point", - coordinates: [5, 5] -}; - -var indexSpec = { - geo: "2dsphere", - nonGeo: 1 -}; +var point = {type: "Point", coordinates: [5, 5]}; + +var indexSpec = {geo: "2dsphere", nonGeo: 1}; var indexName = 'test.geo_s2sparse.$geo_2dsphere_nonGeo_1'; diff --git a/jstests/core/geo_s2twofields.js b/jstests/core/geo_s2twofields.js index 1868287cf5b..564d6fcd91a 100644 --- a/jstests/core/geo_s2twofields.js +++ b/jstests/core/geo_s2twofields.js @@ -13,14 +13,8 @@ function randomCoord(center, minDistDeg, maxDistDeg) { return [center[0] + dx, center[1] + dy]; } -var nyc = { - type: "Point", - coordinates: [-74.0064, 40.7142] -}; -var miami = { - type: "Point", - coordinates: [-80.1303, 25.7903] -}; +var nyc = {type: "Point", coordinates: [-74.0064, 40.7142]}; +var miami = {type: "Point", coordinates: [-80.1303, 25.7903]}; var maxPoints = 10000; var degrees = 5; @@ -29,10 +23,8 @@ for (var i = 0; i < maxPoints; ++i) { var fromCoord = randomCoord(nyc.coordinates, 0, degrees); var toCoord = randomCoord(miami.coordinates, 0, degrees); - arr.push({ - from: {type: "Point", coordinates: fromCoord}, - to: {type: "Point", coordinates: toCoord} - }); + arr.push( + {from: {type: "Point", coordinates: fromCoord}, to: {type: "Point", coordinates: toCoord}}); } res = t.insert(arr); assert.writeOK(res); @@ -65,31 +57,25 @@ function timeWithoutAndWithAnIndex(index, query) { var maxQueryRad = 0.5 * PI / 180.0; // When we're not looking at ALL the data, anything indexed should beat not-indexed. -var smallQuery = - timeWithoutAndWithAnIndex({to: "2dsphere", from: "2dsphere"}, - { - from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, - to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} - }); +var smallQuery = timeWithoutAndWithAnIndex({to: "2dsphere", from: "2dsphere"}, { + from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, + to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +}); print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); // assert(smallQuery[0] > smallQuery[1]); // Let's just index one field. -var smallQuery = - timeWithoutAndWithAnIndex({to: "2dsphere"}, - { - from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, - to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} - }); +var smallQuery = timeWithoutAndWithAnIndex({to: "2dsphere"}, { + from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, + to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +}); print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); // assert(smallQuery[0] > smallQuery[1]); // And the other one. -var smallQuery = - timeWithoutAndWithAnIndex({from: "2dsphere"}, - { - from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, - to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} - }); +var smallQuery = timeWithoutAndWithAnIndex({from: "2dsphere"}, { + from: {$within: {$centerSphere: [nyc.coordinates, maxQueryRad]}}, + to: {$within: {$centerSphere: [miami.coordinates, maxQueryRad]}} +}); print("Indexed time " + smallQuery[1] + " unindexed " + smallQuery[0]); // assert(smallQuery[0] > smallQuery[1]); diff --git a/jstests/core/geo_uniqueDocs.js b/jstests/core/geo_uniqueDocs.js index 8c4e11fc82e..d66d5243c01 100644 --- a/jstests/core/geo_uniqueDocs.js +++ b/jstests/core/geo_uniqueDocs.js @@ -36,9 +36,9 @@ assert.eq(2, t.find({locs: {$within: {$center: [[5, 5], 7], $uniqueDocs: false}} assert.eq(2, t.find({locs: {$within: {$centerSphere: [[5, 5], 1], $uniqueDocs: true}}}).itcount()); assert.eq(2, t.find({locs: {$within: {$centerSphere: [[5, 5], 1], $uniqueDocs: false}}}).itcount()); -assert.eq(2, - t.find({locs: {$within: {$polygon: [[0, 0], [0, 9], [9, 9]], $uniqueDocs: true}}}) - .itcount()); -assert.eq(2, - t.find({locs: {$within: {$polygon: [[0, 0], [0, 9], [9, 9]], $uniqueDocs: false}}}) - .itcount()); +assert.eq( + 2, + t.find({locs: {$within: {$polygon: [[0, 0], [0, 9], [9, 9]], $uniqueDocs: true}}}).itcount()); +assert.eq( + 2, + t.find({locs: {$within: {$polygon: [[0, 0], [0, 9], [9, 9]], $uniqueDocs: false}}}).itcount()); diff --git a/jstests/core/geo_uniqueDocs2.js b/jstests/core/geo_uniqueDocs2.js index f6481b30f41..6f5ceed3478 100644 --- a/jstests/core/geo_uniqueDocs2.js +++ b/jstests/core/geo_uniqueDocs2.js @@ -54,30 +54,27 @@ assert(notUniqueInclude.results[0].loc); assert(uniqueInclude.results[0].loc); // For geoNear / uniqueDocs, 'num' limit seems to apply to locs. -assert.eq( - 1, - db.runCommand( - {geoNear: collName, near: [50, 50], num: 1, uniqueDocs: false, includeLocs: false}) - .results.length); +assert.eq(1, + db.runCommand( + {geoNear: collName, near: [50, 50], num: 1, uniqueDocs: false, includeLocs: false}) + .results.length); // Check locs returned in includeLocs mode. t.remove({}); objLocs = [{x: 20, y: 30, z: ['loc1', 'loca']}, {x: 40, y: 50, z: ['loc2', 'locb']}]; t.save({loc: objLocs}); -results = - db.runCommand( - {geoNear: collName, near: [50, 50], num: 10, uniqueDocs: false, includeLocs: true}) - .results; +results = db.runCommand( + {geoNear: collName, near: [50, 50], num: 10, uniqueDocs: false, includeLocs: true}) + .results; assert.contains(results[0].loc, objLocs); // Check locs returned in includeLocs mode, where locs are arrays. t.remove({}); arrLocs = [[20, 30], [40, 50]]; t.save({loc: arrLocs}); -results = - db.runCommand( - {geoNear: collName, near: [50, 50], num: 10, uniqueDocs: false, includeLocs: true}) - .results; +results = db.runCommand( + {geoNear: collName, near: [50, 50], num: 10, uniqueDocs: false, includeLocs: true}) + .results; // The original loc arrays are returned as objects. expectedLocs = arrLocs; diff --git a/jstests/core/geo_update_btree.js b/jstests/core/geo_update_btree.js index ea1025b10a9..a85d4274415 100644 --- a/jstests/core/geo_update_btree.js +++ b/jstests/core/geo_update_btree.js @@ -19,16 +19,13 @@ var parallelInsert = startParallelShell( " db.jstests_geo_update_btree.insert(doc);" + "}"); for (i = 0; i < 1000; i++) { - coll.update( - { - loc: { - $within: - {$center: [[Random.rand() * 180, Random.rand() * 180], Random.rand() * 50]} - } - }, - {$set: {v: big}}, - false, - true); + coll.update({ + loc: + {$within: {$center: [[Random.rand() * 180, Random.rand() * 180], Random.rand() * 50]}} + }, + {$set: {v: big}}, + false, + true); if (i % 10 == 0) print(i); diff --git a/jstests/core/geo_update_dedup.js b/jstests/core/geo_update_dedup.js index b354f3ca7ae..a630954e8ca 100644 --- a/jstests/core/geo_update_dedup.js +++ b/jstests/core/geo_update_dedup.js @@ -9,9 +9,7 @@ t.drop(); t.ensureIndex({locs: "2d"}); t.save({locs: [[49.999, 49.999], [50.0, 50.0], [50.001, 50.001]]}); -var q = { - locs: {$near: [50.0, 50.0]} -}; +var q = {locs: {$near: [50.0, 50.0]}}; assert.eq(1, t.find(q).itcount(), 'duplicates returned from query'); var res = t.update({locs: {$near: [50.0, 50.0]}}, {$inc: {touchCount: 1}}, false, true); diff --git a/jstests/core/geo_withinquery.js b/jstests/core/geo_withinquery.js index 3a71608ab6d..7f712ba1e86 100644 --- a/jstests/core/geo_withinquery.js +++ b/jstests/core/geo_withinquery.js @@ -5,15 +5,16 @@ t.drop(); num = 0; for (x = 0; x <= 20; x++) { for (y = 0; y <= 20; y++) { - o = { - _id: num++, - loc: [x, y] - }; + o = {_id: num++, loc: [x, y]}; t.save(o); } } assert.eq(21 * 21 - 1, - t.find({$and: [{loc: {$ne: [0, 0]}}, {loc: {$within: {$box: [[0, 0], [100, 100]]}}}, ]}) - .itcount(), + t.find({ + $and: [ + {loc: {$ne: [0, 0]}}, + {loc: {$within: {$box: [[0, 0], [100, 100]]}}}, + ] + }).itcount(), "UHOH!"); diff --git a/jstests/core/geob.js b/jstests/core/geob.js index b78eaa453df..c711a676b2b 100644 --- a/jstests/core/geob.js +++ b/jstests/core/geob.js @@ -1,18 +1,10 @@ var t = db.geob; t.drop(); -var a = { - p: [0, 0] -}; -var b = { - p: [1, 0] -}; -var c = { - p: [3, 4] -}; -var d = { - p: [0, 6] -}; +var a = {p: [0, 0]}; +var b = {p: [1, 0]}; +var c = {p: [3, 4]}; +var d = {p: [0, 6]}; t.save(a); t.save(b); diff --git a/jstests/core/geof.js b/jstests/core/geof.js index 1d7f13eb881..4eae803a856 100644 --- a/jstests/core/geof.js +++ b/jstests/core/geof.js @@ -13,9 +13,7 @@ t.insert({loc: [-0.9, 0]}); t.ensureIndex({loc: "2d"}); -t.find({loc: {$near: [0, 0]}}) - .limit(2) - .forEach(function(o) { - // printjson(o); - assert.lt(Geo.distance([0, 0], o.loc), 0.95); - }); +t.find({loc: {$near: [0, 0]}}).limit(2).forEach(function(o) { + // printjson(o); + assert.lt(Geo.distance([0, 0], o.loc), 0.95); +}); diff --git a/jstests/core/geonear_cmd_input_validation.js b/jstests/core/geonear_cmd_input_validation.js index ad3d56d240a..f9cfaa4ff21 100644 --- a/jstests/core/geonear_cmd_input_validation.js +++ b/jstests/core/geonear_cmd_input_validation.js @@ -24,11 +24,7 @@ indexTypes.forEach(function(indexType) { pointDescription = (isLegacy ? "legacy coordinates" : "GeoJSON point"); function makeCommand(distance) { - var command = { - geoNear: t.getName(), - near: pointType, - spherical: spherical - }; + var command = {geoNear: t.getName(), near: pointType, spherical: spherical}; command[optionName] = distance; return command; } @@ -59,16 +55,14 @@ indexTypes.forEach(function(indexType) { } // Try several bad values for min/maxDistance. - badNumbers.concat(outOfRangeDistances) - .forEach(function(badDistance) { + badNumbers.concat(outOfRangeDistances).forEach(function(badDistance) { - var msg = - ("geoNear with spherical=" + spherical + " and " + pointDescription + - " and " + indexType + " index should've failed with " + optionName + - " " + badDistance); + var msg = ("geoNear with spherical=" + spherical + " and " + pointDescription + + " and " + indexType + " index should've failed with " + optionName + + " " + badDistance); - assert.commandFailed(db.runCommand(makeCommand(badDistance)), msg); - }); + assert.commandFailed(db.runCommand(makeCommand(badDistance)), msg); + }); // Bad values for limit / num. ['num', 'limit'].forEach(function(limitOptionName) { diff --git a/jstests/core/getlog2.js b/jstests/core/getlog2.js index b6cf223b967..597a85e20ee 100644 --- a/jstests/core/getlog2.js +++ b/jstests/core/getlog2.js @@ -26,15 +26,14 @@ if (db.isMaster().msg != "isdbgrid") { }); // run a slow update - glcol.update( - { - "SENTINEL": 1, - "$where": function() { - sleep(1000); - return true; - } - }, - {"x": "x"}); + glcol.update({ + "SENTINEL": 1, + "$where": function() { + sleep(1000); + return true; + } + }, + {"x": "x"}); var resp = db.adminCommand({getLog: "global"}); assert(resp.ok == 1, "error executing getLog command"); @@ -42,21 +41,19 @@ if (db.isMaster().msg != "isdbgrid") { assert(resp.log.length > 0, "no log lines"); // ensure that slow query is logged in detail - assert(contains(resp.log, - function(v) { - print(v); - var opString = db.getMongo().useReadCommands() ? " find " : " query "; - var filterString = db.getMongo().useReadCommands() ? "filter:" : "query:"; - return v.indexOf(opString) != -1 && v.indexOf(filterString) != -1 && - v.indexOf("keysExamined:") != -1 && v.indexOf("docsExamined:") != -1 && - v.indexOf("SENTINEL") != -1; - })); + assert(contains(resp.log, function(v) { + print(v); + var opString = db.getMongo().useReadCommands() ? " find " : " query "; + var filterString = db.getMongo().useReadCommands() ? "filter:" : "query:"; + return v.indexOf(opString) != -1 && v.indexOf(filterString) != -1 && + v.indexOf("keysExamined:") != -1 && v.indexOf("docsExamined:") != -1 && + v.indexOf("SENTINEL") != -1; + })); // same, but for update - assert(contains(resp.log, - function(v) { - return v.indexOf(" update ") != -1 && v.indexOf("query") != -1 && - v.indexOf("keysExamined:") != -1 && v.indexOf("docsExamined:") != -1 && - v.indexOf("SENTINEL") != -1; - })); + assert(contains(resp.log, function(v) { + return v.indexOf(" update ") != -1 && v.indexOf("query") != -1 && + v.indexOf("keysExamined:") != -1 && v.indexOf("docsExamined:") != -1 && + v.indexOf("SENTINEL") != -1; + })); } diff --git a/jstests/core/group1.js b/jstests/core/group1.js index 6100ee94c70..5e4fcdea245 100644 --- a/jstests/core/group1.js +++ b/jstests/core/group1.js @@ -88,9 +88,8 @@ p = { initial: {count: 0}, finalize: "abc" }; -assert.commandFailedWithCode(db.runCommand({group: p}), - ErrorCodes.JSInterpreterFailure, - "Illegal finalize function"); +assert.commandFailedWithCode( + db.runCommand({group: p}), ErrorCodes.JSInterpreterFailure, "Illegal finalize function"); p = { ns: "group1", @@ -103,9 +102,8 @@ p = { ob; } }; -assert.commandFailedWithCode(db.runCommand({group: p}), - ErrorCodes.JSInterpreterFailure, - "Illegal finalize function 2"); +assert.commandFailedWithCode( + db.runCommand({group: p}), ErrorCodes.JSInterpreterFailure, "Illegal finalize function 2"); p = { ns: "group1", @@ -118,9 +116,8 @@ p = { ob; } }; -assert.commandFailedWithCode(db.runCommand({group: p}), - ErrorCodes.JSInterpreterFailure, - "Illegal keyf function"); +assert.commandFailedWithCode( + db.runCommand({group: p}), ErrorCodes.JSInterpreterFailure, "Illegal keyf function"); p = { ns: "group1", @@ -128,9 +125,8 @@ p = { $reduce: "abc", initial: {count: 0} }; -assert.commandFailedWithCode(db.runCommand({group: p}), - ErrorCodes.JSInterpreterFailure, - "Illegal reduce function"); +assert.commandFailedWithCode( + db.runCommand({group: p}), ErrorCodes.JSInterpreterFailure, "Illegal reduce function"); p = { ns: "group1", @@ -140,8 +136,7 @@ p = { }, initial: {count: 0} }; -assert.commandFailedWithCode(db.runCommand({group: p}), - ErrorCodes.JSInterpreterFailure, - "Illegal reduce function 2"); +assert.commandFailedWithCode( + db.runCommand({group: p}), ErrorCodes.JSInterpreterFailure, "Illegal reduce function 2"); t.drop(); diff --git a/jstests/core/group2.js b/jstests/core/group2.js index ada675f6f69..1577932beca 100644 --- a/jstests/core/group2.js +++ b/jstests/core/group2.js @@ -25,9 +25,7 @@ assert.eq(1, result[1].count, "G"); assert.eq(1, result[2].count, "H"); var keyFn = function(x) { - return { - a: 'a' in x ? x.a : null - }; + return {a: 'a' in x ? x.a : null}; }; delete cmd.key; diff --git a/jstests/core/grow_hash_table.js b/jstests/core/grow_hash_table.js index b26baae31af..d35ffa65405 100644 --- a/jstests/core/grow_hash_table.js +++ b/jstests/core/grow_hash_table.js @@ -11,12 +11,8 @@ var testDB = db.getSiblingDB('grow_hash_table'); var doTest = function(count) { print('Testing with count of ' + count); testDB.dropDatabase(); - var id = { - data: 1 - }; - var doc = { - _id: id - }; + var id = {data: 1}; + var doc = {_id: id}; var projection = {}; // Create a document and a projection with fields r1, r2, r3 ... diff --git a/jstests/core/hashindex1.js b/jstests/core/hashindex1.js index 778e31d84b2..93986ecfd5e 100644 --- a/jstests/core/hashindex1.js +++ b/jstests/core/hashindex1.js @@ -5,17 +5,12 @@ t.drop(); load("jstests/libs/analyze_plan.js"); // test non-single field hashed indexes don't get created (maybe change later) -var badspec = { - a: "hashed", - b: 1 -}; +var badspec = {a: "hashed", b: 1}; t.ensureIndex(badspec); assert.eq(t.getIndexes().length, 1, "only _id index should be created"); // test unique index not created (maybe change later) -var goodspec = { - a: "hashed" -}; +var goodspec = {a: "hashed"}; t.ensureIndex(goodspec, {"unique": true}); assert.eq(t.getIndexes().length, 1, "unique index got created."); @@ -67,9 +62,7 @@ var explain = t.find({$and: [{a: {$in: [1, 2]}}, {a: {$gt: 1}}]}).explain(); assert(isIxscan(explain.queryPlanner.winningPlan), "not using hashed index"); // test creation of index based on hash of _id index -var goodspec2 = { - '_id': "hashed" -}; +var goodspec2 = {'_id': "hashed"}; t.ensureIndex(goodspec2); assert.eq(t.getIndexes().length, 3, "_id index didn't get created"); @@ -79,9 +72,7 @@ assert.eq(t.find({_id: newid}).hint({_id: 1}).toArray()[0]._id, "using hashed index and different index returns different docs"); // test creation of sparse hashed index -var sparseindex = { - b: "hashed" -}; +var sparseindex = {b: "hashed"}; t.ensureIndex(sparseindex, {"sparse": true}); assert.eq(t.getIndexes().length, 4, "sparse index didn't get created"); diff --git a/jstests/core/hint1.js b/jstests/core/hint1.js index ddee0f369be..6542f9752bc 100644 --- a/jstests/core/hint1.js +++ b/jstests/core/hint1.js @@ -4,13 +4,10 @@ p.drop(); p.save({ts: new Date(1), cls: "entry", verticals: "alleyinsider", live: true}); p.ensureIndex({ts: 1}); -assert.eq(1, - p.find({ - live: true, - ts: {$lt: new Date(1234119308272)}, - cls: "entry", - verticals: "alleyinsider" - }) - .sort({ts: -1}) - .hint({ts: 1}) - .count()); +assert.eq( + 1, + p.find( + {live: true, ts: {$lt: new Date(1234119308272)}, cls: "entry", verticals: "alleyinsider"}) + .sort({ts: -1}) + .hint({ts: 1}) + .count()); diff --git a/jstests/core/idhack.js b/jstests/core/idhack.js index 292c2ed86b6..e26427f4b3c 100644 --- a/jstests/core/idhack.js +++ b/jstests/core/idhack.js @@ -25,9 +25,7 @@ assert.eq(8, t.findOne({_id: 2}).z, "C2"); assert.eq(8, t.findOne({_id: 3}).z, "C3"); // explain output should show that the ID hack was applied. -var query = { - _id: {x: 2} -}; +var query = {_id: {x: 2}}; var explain = t.find(query).explain(true); print("explain for " + tojson(query, "", true) + " = " + tojson(explain)); assert.eq(1, explain.executionStats.nReturned, "D1"); @@ -67,11 +65,10 @@ assert.eq({_id: 0, a: 0}, t.find({_id: 0}, {_id: 1, a: 1}).next()); // Non-simple: exclusion. assert.eq({_id: 1, a: 1}, t.find({_id: 1}, {b: 0}).next()); -assert.eq( - { - _id: 0, - }, - t.find({_id: 0}, {a: 0, b: 0}).next()); +assert.eq({ + _id: 0, +}, + t.find({_id: 0}, {a: 0, b: 0}).next()); // Non-simple: dotted fields. assert.eq({b: [{c: 1}, {c: 2}]}, t.find({_id: 0}, {_id: 0, "b.c": 1}).next()); diff --git a/jstests/core/in5.js b/jstests/core/in5.js index c56621c91f3..772427365b7 100644 --- a/jstests/core/in5.js +++ b/jstests/core/in5.js @@ -4,30 +4,20 @@ t = db.in5; function go(fn) { t.drop(); o = {}; - o[fn] = { - a: 1, - b: 2 - }; + o[fn] = {a: 1, b: 2}; t.insert(o); x = {}; - x[fn] = { - a: 1, - b: 2 - }; + x[fn] = {a: 1, b: 2}; assert.eq(1, t.find(x).itcount(), "A1 - " + fn); y = {}; - y[fn] = { - $in: [{a: 1, b: 2}] - }; + y[fn] = {$in: [{a: 1, b: 2}]}; assert.eq(1, t.find(y).itcount(), "A2 - " + fn); z = {}; z[fn + ".a"] = 1; - z[fn + ".b"] = { - $in: [2] - }; + z[fn + ".b"] = {$in: [2]}; assert.eq(1, t.find(z).itcount(), "A3 - " + fn); // SERVER-1366 i = {}; diff --git a/jstests/core/index_arr2.js b/jstests/core/index_arr2.js index 952be73ff13..a7e541add09 100644 --- a/jstests/core/index_arr2.js +++ b/jstests/core/index_arr2.js @@ -7,10 +7,7 @@ function test(withIndex) { t.drop(); // insert a bunch of items to force queries to use the index. - newObject = { - _id: 1, - a: [{b: {c: 1}}] - }; + newObject = {_id: 1, a: [{b: {c: 1}}]}; now = (new Date()).getTime() / 1000; for (created = now - NUM; created <= now; created++) { @@ -20,9 +17,7 @@ function test(withIndex) { } // change the last M items. - query = { - 'created': {'$gte': now - M} - }; + query = {'created': {'$gte': now - M}}; Z = t.find(query).count(); diff --git a/jstests/core/index_check3.js b/jstests/core/index_check3.js index 2c07ae6d50a..7ffcc8da411 100644 --- a/jstests/core/index_check3.js +++ b/jstests/core/index_check3.js @@ -19,9 +19,7 @@ assert.eq(1, t.find({a: {$gt: 2}}).itcount(), "D"); t.drop(); for (var i = 0; i < 100; i++) { - var o = { - i: i - }; + var o = {i: i}; if (i % 2 == 0) o.foo = i; t.save(o); diff --git a/jstests/core/index_check6.js b/jstests/core/index_check6.js index 4baeced8fb9..e85913aeec3 100644 --- a/jstests/core/index_check6.js +++ b/jstests/core/index_check6.js @@ -30,10 +30,10 @@ assert.eq(29, assert.eq(5, keysExamined({age: {$gte: 29, $lte: 30}, rating: 5}, {age: 1, rating: 1}), "C"); // SERVER-371 -assert.eq(7, - keysExamined({age: {$gte: 29, $lte: 30}, rating: {$gte: 4, $lte: 5}}, - {age: 1, rating: 1}), - "D"); // SERVER-371 +assert.eq( + 7, + keysExamined({age: {$gte: 29, $lte: 30}, rating: {$gte: 4, $lte: 5}}, {age: 1, rating: 1}), + "D"); // SERVER-371 assert.eq.automsg("2", "t.find( { age:30, rating:{ $gte:4, $lte:5} } )" + ".explain('executionStats')" + @@ -91,11 +91,7 @@ for (var a = -1; a <= 1; a += 2) { for (var b = -1; b <= 1; b += 2) { for (var c = -1; c <= 1; c += 2) { t.dropIndexes(); - var spec = { - a: a, - b: b, - c: c - }; + var spec = {a: a, b: b, c: c}; t.ensureIndex(spec); doTest(spec, spec); doTest({a: -a, b: -b, c: -c}, spec); diff --git a/jstests/core/index_create_too_many.js b/jstests/core/index_create_too_many.js index 44d5016a7cf..0b2002d9cc1 100644 --- a/jstests/core/index_create_too_many.js +++ b/jstests/core/index_create_too_many.js @@ -6,10 +6,7 @@ coll.drop(); // create 62 indexes, which leaves us with 63 indexes total (+1 for the _id index) for (var i = 0; i < 62; i++) { var name = 'i' + i; - var spec = { - key: {}, - name: name - }; + var spec = {key: {}, name: name}; spec.key[name] = 1; var res = coll.runCommand('createIndexes', {indexes: [spec]}); diff --git a/jstests/core/index_create_with_nul_in_name.js b/jstests/core/index_create_with_nul_in_name.js index 9134649c086..c128dcc5880 100644 --- a/jstests/core/index_create_with_nul_in_name.js +++ b/jstests/core/index_create_with_nul_in_name.js @@ -6,11 +6,7 @@ var coll = db.create_index_with_nul_in_name; coll.drop(); - var idx = { - key: {'a': 1}, - name: 'foo\0bar', - ns: coll.getFullName() - }; + var idx = {key: {'a': 1}, name: 'foo\0bar', ns: coll.getFullName()}; var res = coll.runCommand('createIndexes', {indexes: [idx]}); assert.commandFailed(res, tojson(res)); diff --git a/jstests/core/index_diag.js b/jstests/core/index_diag.js index 3e25bf2a1eb..e458a590dda 100644 --- a/jstests/core/index_diag.js +++ b/jstests/core/index_diag.js @@ -16,10 +16,7 @@ function r(a) { } for (i = 1; i < 4; i++) { - o = { - _id: i, - x: -i - }; + o = {_id: i, x: -i}; t.insert(o); all.push(o); ids.push({_id: i}); diff --git a/jstests/core/index_filter_commands.js b/jstests/core/index_filter_commands.js index 027731e97cf..8d00d69cbe7 100644 --- a/jstests/core/index_filter_commands.js +++ b/jstests/core/index_filter_commands.js @@ -36,32 +36,16 @@ t.save({a: 1, b: 1}); // Add 2 indexes. // 1st index is more efficient. // 2nd and 3rd indexes will be used to test index filters. -var indexA1 = { - a: 1 -}; -var indexA1B1 = { - a: 1, - b: 1 -}; -var indexA1C1 = { - a: 1, - c: 1 -}; +var indexA1 = {a: 1}; +var indexA1B1 = {a: 1, b: 1}; +var indexA1C1 = {a: 1, c: 1}; t.ensureIndex(indexA1); t.ensureIndex(indexA1B1); t.ensureIndex(indexA1C1); -var queryA1 = { - a: 1, - b: 1 -}; -var projectionA1 = { - _id: 0, - a: 1 -}; -var sortA1 = { - a: -1 -}; +var queryA1 = {a: 1, b: 1}; +var projectionA1 = {_id: 0, a: 1}; +var sortA1 = {a: -1}; // // Tests for planCacheListFilters, planCacheClearFilters, planCacheSetFilter @@ -110,17 +94,12 @@ assert.eq(0, filters.length, 'unexpected number of index filters in planCacheLis // Check details of winning plan in plan cache before setting index filter. assert.eq(1, t.find(queryA1, projectionA1).sort(sortA1).itcount(), 'unexpected document count'); -var shape = { - query: queryA1, - sort: sortA1, - projection: projectionA1 -}; +var shape = {query: queryA1, sort: sortA1, projection: projectionA1}; var planBeforeSetFilter = getPlans(shape)[0]; print('Winning plan (before setting index filters) = ' + tojson(planBeforeSetFilter)); // Check filterSet field in plan details -assert.eq(false, - planBeforeSetFilter.filterSet, - 'missing or invalid filterSet field in plan details'); +assert.eq( + false, planBeforeSetFilter.filterSet, 'missing or invalid filterSet field in plan details'); // Adding index filters to a non-existent collection should be an error. assert.commandFailed(missingCollection.runCommand( @@ -132,9 +111,8 @@ assert.commandWorked(t.runCommand( 'planCacheSetFilter', {query: queryA1, sort: sortA1, projection: projectionA1, indexes: [indexA1B1, indexA1C1]})); filters = getFilters(); -assert.eq(1, - filters.length, - 'no change in query settings after successfully setting index filters'); +assert.eq( + 1, filters.length, 'no change in query settings after successfully setting index filters'); assert.eq(queryA1, filters[0].query, 'unexpected query in filters'); assert.eq(sortA1, filters[0].sort, 'unexpected sort in filters'); assert.eq(projectionA1, filters[0].projection, 'unexpected projection in filters'); @@ -196,13 +174,9 @@ if (db.isMaster().msg !== "isdbgrid") { .queryPlanner.indexFilterSet); // With two filters set. - assert.commandWorked(t.runCommand('planCacheSetFilter', - { - query: queryA1, - projection: projectionA1, - sort: sortA1, - indexes: [indexA1B1, indexA1C1] - })); + assert.commandWorked(t.runCommand( + 'planCacheSetFilter', + {query: queryA1, projection: projectionA1, sort: sortA1, indexes: [indexA1B1, indexA1C1]})); assert.eq(true, t.find({z: 1}).explain('queryPlanner').queryPlanner.indexFilterSet); assert.eq(true, t.find(queryA1, projectionA1) diff --git a/jstests/core/index_many.js b/jstests/core/index_many.js index 142c9bbc4a5..f2daa8c9fcf 100644 --- a/jstests/core/index_many.js +++ b/jstests/core/index_many.js @@ -15,13 +15,9 @@ function f() { patt = {}; patt[x] = 1; if (x == 20) - patt = { - x: 1 - }; + patt = {x: 1}; if (x == 64) - patt = { - y: 1 - }; + patt = {y: 1}; lastErr = t.ensureIndex(patt); x++; } diff --git a/jstests/core/index_partial_create_drop.js b/jstests/core/index_partial_create_drop.js index 483dc26f5e5..1c8552804b3 100644 --- a/jstests/core/index_partial_create_drop.js +++ b/jstests/core/index_partial_create_drop.js @@ -24,12 +24,10 @@ assert.commandFailed(coll.ensureIndex({x: 1}, {partialFilterExpression: {x: {$asdasd: 3}}})); assert.commandFailed(coll.ensureIndex({x: 1}, {partialFilterExpression: {$and: 5}})); assert.commandFailed(coll.ensureIndex({x: 1}, {partialFilterExpression: {x: /abc/}})); - assert.commandFailed(coll.ensureIndex( - {x: 1}, - { - partialFilterExpression: - {$and: [{$and: [{x: {$lt: 2}}, {x: {$gt: 0}}]}, {x: {$exists: true}}]} - })); + assert.commandFailed(coll.ensureIndex({x: 1}, { + partialFilterExpression: + {$and: [{$and: [{x: {$lt: 2}}, {x: {$gt: 0}}]}, {x: {$exists: true}}]} + })); for (var i = 0; i < 10; i++) { assert.writeOK(coll.insert({x: i, a: i})); diff --git a/jstests/core/index_stats.js b/jstests/core/index_stats.js index 7db4559210c..16d5a16d8d2 100644 --- a/jstests/core/index_stats.js +++ b/jstests/core/index_stats.js @@ -78,8 +78,8 @@ // // Confirm index stats tick on findAndModify() update. // - var res = db.runCommand( - {findAndModify: colName, query: {a: 1}, update: {$set: {d: 1}}, 'new': true}); + var res = + db.runCommand({findAndModify: colName, query: {a: 1}, update: {$set: {d: 1}}, 'new': true}); assert.commandWorked(res); countA++; assert.eq(countA, getUsageCount("a_1")); diff --git a/jstests/core/indexu.js b/jstests/core/indexu.js index 923356bf79b..088f0b86d44 100644 --- a/jstests/core/indexu.js +++ b/jstests/core/indexu.js @@ -4,15 +4,9 @@ t = db.jstests_indexu; t.drop(); -var dupDoc = { - a: [{'0': 1}] -}; // There are two 'a.0' fields in this doc. -var dupDoc2 = { - a: [{'1': 1}, 'c'] -}; -var noDupDoc = { - a: [{'1': 1}] -}; +var dupDoc = {a: [{'0': 1}]}; // There are two 'a.0' fields in this doc. +var dupDoc2 = {a: [{'1': 1}, 'c']}; +var noDupDoc = {a: [{'1': 1}]}; // Test that we can't index dupDoc. assert.writeOK(t.save(dupDoc)); diff --git a/jstests/core/insert1.js b/jstests/core/insert1.js index 0f4f6977a1a..d6886491999 100644 --- a/jstests/core/insert1.js +++ b/jstests/core/insert1.js @@ -1,9 +1,7 @@ t = db.insert1; t.drop(); -var o = { - a: 1 -}; +var o = {a: 1}; t.insert(o); var doc = t.findOne(); assert.eq(1, doc.a); diff --git a/jstests/core/js1.js b/jstests/core/js1.js index 89910f4bd23..66462237417 100644 --- a/jstests/core/js1.js +++ b/jstests/core/js1.js @@ -6,17 +6,15 @@ t.remove({}); t.save({z: 1}); t.save({z: 2}); assert(2 == t.find().length()); -assert(2 == - t.find({ - $where: function() { - return 1; - } - }).length()); -assert(1 == - t.find({ - $where: function() { - return obj.z == 2; - } - }).length()); +assert(2 == t.find({ + $where: function() { + return 1; + } + }).length()); +assert(1 == t.find({ + $where: function() { + return obj.z == 2; + } + }).length()); assert(t.validate().valid); diff --git a/jstests/core/js2.js b/jstests/core/js2.js index 9dfb5c0b091..abd707fdbbd 100644 --- a/jstests/core/js2.js +++ b/jstests/core/js2.js @@ -11,11 +11,11 @@ t.save({z: 1}); t.save({z: 2}); assert.throws(function() { t.find({ - $where: function() { - db.jstests_js2_2.save({y: 1}); - return 1; - } - }).forEach(printjson); + $where: function() { + db.jstests_js2_2.save({y: 1}); + return 1; + } + }).forEach(printjson); }, null, "can't save from $where"); assert.eq(0, t2.find().length(), "B"); diff --git a/jstests/core/js3.js b/jstests/core/js3.js index 36d16051135..4d46c25bbf7 100644 --- a/jstests/core/js3.js +++ b/jstests/core/js3.js @@ -18,14 +18,12 @@ for (z = 0; z < 2; z++) { for (i = 0; i < 1000; i++) t.save({ i: i, - z: - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + z: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }); - assert(33 == - db.dbEval(function() { - return 33; - })); + assert(33 == db.dbEval(function() { + return 33; + })); db.dbEval(function() { db.jstests_js3.save({i: -1, z: "server side"}); @@ -33,12 +31,11 @@ for (z = 0; z < 2; z++) { assert(t.findOne({i: -1})); - assert(2 == - t.find({ - $where: function() { - return obj.i == 7 || obj.i == 8; - } - }).length()); + assert(2 == t.find({ + $where: function() { + return obj.i == 7 || obj.i == 8; + } + }).length()); // NPE test var ok = false; @@ -62,10 +59,10 @@ for (z = 0; z < 2; z++) { debug("before indexed find"); arr = t.find({ - $where: function() { - return obj.i == 7 || obj.i == 8; - } - }).toArray(); + $where: function() { + return obj.i == 7 || obj.i == 8; + } + }).toArray(); debug(arr); assert.eq(2, arr.length); @@ -74,8 +71,7 @@ for (z = 0; z < 2; z++) { for (i = 1000; i < 2000; i++) t.save({ i: i, - z: - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + z: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }); assert(t.find().count() == 2001); diff --git a/jstests/core/js7.js b/jstests/core/js7.js index aeaec66ff47..810f4692d4f 100644 --- a/jstests/core/js7.js +++ b/jstests/core/js7.js @@ -1,7 +1,6 @@ t = db.jstests_js7; t.drop(); -assert.eq(17, - db.eval(function(foo) { - return foo; - }, 17)); +assert.eq(17, db.eval(function(foo) { + return foo; +}, 17)); diff --git a/jstests/core/js8.js b/jstests/core/js8.js index 15b7ff7d7af..d670abb0587 100644 --- a/jstests/core/js8.js +++ b/jstests/core/js8.js @@ -6,30 +6,30 @@ t.save({a: 1, b: [2, 3, 4]}); assert.eq(1, t.find().length(), "A"); assert.eq(1, t.find(function() { - return this.a == 1; - }).length(), + return this.a == 1; + }).length(), "B"); assert.eq(1, t.find(function() { - if (!this.b.length) - return true; - return this.b.length == 3; - }).length(), + if (!this.b.length) + return true; + return this.b.length == 3; + }).length(), "B2"); assert.eq(1, t.find(function() { - return this.b[0] == 2; - }).length(), + return this.b[0] == 2; + }).length(), "C"); assert.eq(0, t.find(function() { - return this.b[0] == 3; - }).length(), + return this.b[0] == 3; + }).length(), "D"); assert.eq(1, t.find(function() { - return this.b[1] == 3; - }).length(), + return this.b[1] == 3; + }).length(), "E"); assert(t.validate().valid); diff --git a/jstests/core/js9.js b/jstests/core/js9.js index b29a31afdc4..515fa883aea 100644 --- a/jstests/core/js9.js +++ b/jstests/core/js9.js @@ -7,11 +7,10 @@ c.save({a: 2}); assert.eq(2, c.find().length()); assert.eq(2, c.find().count()); -assert.eq(2, - db.eval(function() { - num = 0; - db.jstests_js9.find().forEach(function(z) { - num++; - }); - return num; - })); +assert.eq(2, db.eval(function() { + num = 0; + db.jstests_js9.find().forEach(function(z) { + num++; + }); + return num; +})); diff --git a/jstests/core/list_collections1.js b/jstests/core/list_collections1.js index 04acb82290b..9745adc1f90 100644 --- a/jstests/core/list_collections1.js +++ b/jstests/core/list_collections1.js @@ -46,11 +46,9 @@ assert.commandWorked(mydb.dropDatabase()); assert.commandWorked(mydb.createCollection("foo")); - assert.eq(1, - cursorCountMatching(getListCollectionsCursor(), - function(c) { - return c.name === "foo"; - })); + assert.eq(1, cursorCountMatching(getListCollectionsCursor(), function(c) { + return c.name === "foo"; + })); // // Test that the collection metadata object is returned correctly. @@ -59,16 +57,12 @@ assert.commandWorked(mydb.dropDatabase()); assert.commandWorked(mydb.createCollection("foo")); assert.commandWorked(mydb.createCollection("bar", {temp: true})); - assert.eq(1, - cursorCountMatching(getListCollectionsCursor(), - function(c) { - return c.name === "foo" && c.options.temp === undefined; - })); - assert.eq(1, - cursorCountMatching(getListCollectionsCursor(), - function(c) { - return c.name === "bar" && c.options.temp === true; - })); + assert.eq(1, cursorCountMatching(getListCollectionsCursor(), function(c) { + return c.name === "foo" && c.options.temp === undefined; + })); + assert.eq(1, cursorCountMatching(getListCollectionsCursor(), function(c) { + return c.name === "bar" && c.options.temp === true; + })); // // Test basic usage of "filter" option. @@ -77,29 +71,23 @@ assert.commandWorked(mydb.dropDatabase()); assert.commandWorked(mydb.createCollection("foo")); assert.commandWorked(mydb.createCollection("bar", {temp: true})); - assert.eq(2, - cursorCountMatching(getListCollectionsCursor({filter: {}}), - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(getListCollectionsCursor({filter: {}}), function(c) { + return c.name === "foo" || c.name === "bar"; + })); assert.eq(2, getListCollectionsCursor({filter: {name: {$in: ["foo", "bar"]}}}).itcount()); assert.eq(1, getListCollectionsCursor({filter: {name: /^foo$/}}).itcount()); assert.eq(1, getListCollectionsCursor({filter: {"options.temp": true}}).itcount()); mydb.foo.drop(); - assert.eq(1, - cursorCountMatching(getListCollectionsCursor({filter: {}}), - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(1, cursorCountMatching(getListCollectionsCursor({filter: {}}), function(c) { + return c.name === "foo" || c.name === "bar"; + })); assert.eq(1, getListCollectionsCursor({filter: {name: {$in: ["foo", "bar"]}}}).itcount()); assert.eq(0, getListCollectionsCursor({filter: {name: /^foo$/}}).itcount()); assert.eq(1, getListCollectionsCursor({filter: {"options.temp": true}}).itcount()); mydb.bar.drop(); - assert.eq(0, - cursorCountMatching(getListCollectionsCursor({filter: {}}), - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(0, cursorCountMatching(getListCollectionsCursor({filter: {}}), function(c) { + return c.name === "foo" || c.name === "bar"; + })); assert.eq(0, getListCollectionsCursor({filter: {name: {$in: ["foo", "bar"]}}}).itcount()); assert.eq(0, getListCollectionsCursor({filter: {name: /^foo$/}}).itcount()); assert.eq(0, getListCollectionsCursor({filter: {"options.temp": true}}).itcount()); @@ -130,50 +118,38 @@ assert.commandWorked(mydb.createCollection("bar")); cursor = getListCollectionsCursor({cursor: {batchSize: 2}}); assert.eq(2, cursor.objsLeftInBatch()); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); cursor = getListCollectionsCursor({cursor: {batchSize: 1}}); assert.eq(1, cursor.objsLeftInBatch()); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); cursor = getListCollectionsCursor({cursor: {batchSize: 0}}); assert.eq(0, cursor.objsLeftInBatch()); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); cursor = getListCollectionsCursor({cursor: {batchSize: NumberInt(2)}}); assert.eq(2, cursor.objsLeftInBatch()); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); cursor = getListCollectionsCursor({cursor: {batchSize: NumberLong(2)}}); assert.eq(2, cursor.objsLeftInBatch()); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); // Test a large batch size, and assert that at least 2 results are returned in the initial // batch. cursor = getListCollectionsCursor({cursor: {batchSize: Math.pow(2, 62)}}); assert.lte(2, cursor.objsLeftInBatch()); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); // Ensure that the server accepts an empty object for "cursor". This is equivalent to not // specifying "cursor" at all. @@ -181,11 +157,9 @@ // We do not test for objsLeftInBatch() here, since the default batch size for this command // is not specified. cursor = getListCollectionsCursor({cursor: {}}); - assert.eq(2, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo" || c.name === "bar"; - })); + assert.eq(2, cursorCountMatching(cursor, function(c) { + return c.name === "foo" || c.name === "bar"; + })); // // Test for invalid values of "cursor" and "cursor.batchSize". @@ -245,11 +219,9 @@ assert.commandWorked(mydb.dropDatabase()); cursor = getListCollectionsCursor(); - assert.eq(0, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo"; - })); + assert.eq(0, cursorCountMatching(cursor, function(c) { + return c.name === "foo"; + })); // // Test on empty database. @@ -259,11 +231,9 @@ assert.commandWorked(mydb.createCollection("foo")); mydb.foo.drop(); cursor = getListCollectionsCursor(); - assert.eq(0, - cursorCountMatching(cursor, - function(c) { - return c.name === "foo"; - })); + assert.eq(0, cursorCountMatching(cursor, function(c) { + return c.name === "foo"; + })); // // Test killCursors against a listCollections cursor. diff --git a/jstests/core/list_collections_filter.js b/jstests/core/list_collections_filter.js index 4b5c42bbc78..e0d18f055d0 100644 --- a/jstests/core/list_collections_filter.js +++ b/jstests/core/list_collections_filter.js @@ -67,10 +67,20 @@ // Filter with $and and $in. testListCollections({name: {$in: ["lists", /.*_sets$/]}, options: {}}, ["lists", "ordered_sets", "unordered_sets"]); - testListCollections( - {$and: [{name: {$in: ["lists", /.*_sets$/]}}, {name: "lists"}, {options: {}}, ]}, - ["lists"]); - testListCollections( - {$and: [{name: {$in: ["lists", /.*_sets$/]}}, {name: "non-existent"}, {options: {}}, ]}, - []); + testListCollections({ + $and: [ + {name: {$in: ["lists", /.*_sets$/]}}, + {name: "lists"}, + {options: {}}, + ] + }, + ["lists"]); + testListCollections({ + $and: [ + {name: {$in: ["lists", /.*_sets$/]}}, + {name: "non-existent"}, + {options: {}}, + ] + }, + []); }()); diff --git a/jstests/core/long_index_rename.js b/jstests/core/long_index_rename.js index df3397bbb46..a0bf96aa894 100644 --- a/jstests/core/long_index_rename.js +++ b/jstests/core/long_index_rename.js @@ -11,11 +11,9 @@ for (i = 1; i < 10; i++) { } t.createIndex({a: 1}, {name: "aaa"}); -var result = t.createIndex( - {a: 1}, - { - name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - }); +var result = t.createIndex({a: 1}, { + name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +}); assert(!result.ok); assert(result.errmsg.indexOf("too long") >= 0); diff --git a/jstests/core/max_doc_size.js b/jstests/core/max_doc_size.js index 03deeafb307..383e4b4b76d 100644 --- a/jstests/core/max_doc_size.js +++ b/jstests/core/max_doc_size.js @@ -53,10 +53,7 @@ assert.neq(null, res.writeErrors); coll.drop(); id = new ObjectId(); coll.insert({_id: id}); -res = db.runCommand({ - update: coll.getName(), - ordered: true, - updates: [{q: {_id: id}, u: {$set: {x: overBigStr}}}] -}); +res = db.runCommand( + {update: coll.getName(), ordered: true, updates: [{q: {_id: id}, u: {$set: {x: overBigStr}}}]}); assert(res.ok); assert.neq(null, res.writeErrors); diff --git a/jstests/core/mr1.js b/jstests/core/mr1.js index 0225ab3cb62..00a5726db0d 100644 --- a/jstests/core/mr1.js +++ b/jstests/core/mr1.js @@ -34,9 +34,7 @@ r = function(key, values) { for (var i = 0; i < values.length; i++) { total += values[i].count; } - return { - count: total - }; + return {count: total}; }; r2 = function(key, values) { @@ -136,19 +134,14 @@ if (true) { printjson(db.runCommand({mapreduce: "mr1", map: m, reduce: r, verbose: true, out: "mr1_out"})); } -print("t1: " + - Date.timeFunc( - function() { - var out = db.runCommand({mapreduce: "mr1", map: m, reduce: r, out: "mr1_out"}); - if (ks == "_id") - assert(out.ok, "XXX : " + tojson(out)); - db[out.result].drop(); - }, - 10) + - " (~500 on 2.8ghz) - itcount: " + - Date.timeFunc(function() { - db.mr1.find().itcount(); - }, 10)); +print("t1: " + Date.timeFunc(function() { + var out = db.runCommand({mapreduce: "mr1", map: m, reduce: r, out: "mr1_out"}); + if (ks == "_id") + assert(out.ok, "XXX : " + tojson(out)); + db[out.result].drop(); +}, 10) + " (~500 on 2.8ghz) - itcount: " + Date.timeFunc(function() { + db.mr1.find().itcount(); +}, 10)); // test doesn't exist res = @@ -169,10 +162,9 @@ if (true) { res = db.runCommand({mapreduce: "mr1", out: "mr1_foo", map: m, reduce: r}); d(res); - print("t2: " + res.timeMillis + " (~3500 on 2.8ghz) - itcount: " + - Date.timeFunc(function() { - db.mr1.find().itcount(); - })); + print("t2: " + res.timeMillis + " (~3500 on 2.8ghz) - itcount: " + Date.timeFunc(function() { + db.mr1.find().itcount(); + })); x = db[res.result]; z = {}; x.find().forEach(function(a) { diff --git a/jstests/core/mr2.js b/jstests/core/mr2.js index c13ff447970..744fb916088 100644 --- a/jstests/core/mr2.js +++ b/jstests/core/mr2.js @@ -15,10 +15,7 @@ function m() { } function r(who, values) { - var n = { - totalSize: 0, - num: 0 - }; + var n = {totalSize: 0, num: 0}; for (var i = 0; i < values.length; i++) { n.totalSize += values[i].totalSize; n.num += values[i].num; diff --git a/jstests/core/mr3.js b/jstests/core/mr3.js index a2cee1f2d8f..f5a45e0fd1c 100644 --- a/jstests/core/mr3.js +++ b/jstests/core/mr3.js @@ -20,9 +20,7 @@ r = function(key, values) { for (var i = 0; i < values.length; i++) { total += values[i].count; } - return { - count: total - }; + return {count: total}; }; res = t.mapReduce(m, r, {out: "mr3_out"}); diff --git a/jstests/core/mr4.js b/jstests/core/mr4.js index ae5e11528af..58ea303f7e8 100644 --- a/jstests/core/mr4.js +++ b/jstests/core/mr4.js @@ -18,9 +18,7 @@ r = function(key, values) { for (var i = 0; i < values.length; i++) { total += values[i].count; } - return { - count: total - }; + return {count: total}; }; res = t.mapReduce(m, r, {out: "mr4_out", scope: {xx: 1}}); diff --git a/jstests/core/mr5.js b/jstests/core/mr5.js index 537625e954b..8552f891358 100644 --- a/jstests/core/mr5.js +++ b/jstests/core/mr5.js @@ -22,10 +22,7 @@ r = function(k, v) { total += v[i].stats[j]; } } - return { - stats: stats, - total: total - }; + return {stats: stats, total: total}; }; res = t.mapReduce(m, r, {out: "mr5_out", scope: {xx: 1}}); @@ -41,11 +38,7 @@ res.drop(); m = function() { var x = "partner"; var y = "visits"; - emit(this [x], - { - stats: - [this[y]] - }); + emit(this[x], {stats: [this[y]]}); }; res = t.mapReduce(m, r, {out: "mr5_out", scope: {xx: 1}}); diff --git a/jstests/core/mr_bigobject.js b/jstests/core/mr_bigobject.js index d87b2af4cdc..ff8e3cd1652 100644 --- a/jstests/core/mr_bigobject.js +++ b/jstests/core/mr_bigobject.js @@ -41,8 +41,7 @@ r = function(k, v) { return total; }; -assert.eq({1: t.count() * s.length}, - t.mapReduce(m, r, "mr_bigobject_out").convertToSingleObject(), - "A1"); +assert.eq( + {1: t.count() * s.length}, t.mapReduce(m, r, "mr_bigobject_out").convertToSingleObject(), "A1"); t.drop(); diff --git a/jstests/core/mr_bigobject_replace.js b/jstests/core/mr_bigobject_replace.js index 28a295c1b2e..c30b6e5de48 100644 --- a/jstests/core/mr_bigobject_replace.js +++ b/jstests/core/mr_bigobject_replace.js @@ -14,10 +14,7 @@ // Returns a document of the form { _id: ObjectId(...), value: '...' } with the specified // 'targetSize' in bytes. function makeDocWithSize(targetSize) { - var doc = { - _id: new ObjectId(), - value: '' - }; + var doc = {_id: new ObjectId(), value: ''}; var size = Object.bsonsize(doc); assert.gte(targetSize, size); @@ -41,13 +38,12 @@ // Insert a document so the mapper gets run. assert.writeOK(db.input.insert({})); - var res = db.runCommand(Object.extend( - { - mapReduce: "input", - map: mapper, - out: {replace: "mr_bigobject_replace"}, - }, - testOptions)); + var res = db.runCommand(Object.extend({ + mapReduce: "input", + map: mapper, + out: {replace: "mr_bigobject_replace"}, + }, + testOptions)); assert.commandFailed(res, "creating a document larger than 16MB didn't fail"); assert.lte(0, diff --git a/jstests/core/mr_index3.js b/jstests/core/mr_index3.js index bac61cb6bc1..885089ade4d 100644 --- a/jstests/core/mr_index3.js +++ b/jstests/core/mr_index3.js @@ -17,20 +17,16 @@ r = function(key, values) { }; a1 = db.runCommand({mapreduce: 'mr_index3', map: m, reduce: r, out: {inline: true}}).results; -a2 = db.runCommand({ - mapreduce: 'mr_index3', - map: m, - reduce: r, - query: {name: 'name1'}, - out: {inline: true} -}).results; +a2 = db.runCommand( + {mapreduce: 'mr_index3', map: m, reduce: r, query: {name: 'name1'}, out: {inline: true}}) + .results; a3 = db.runCommand({ - mapreduce: 'mr_index3', - map: m, - reduce: r, - query: {name: {$gt: 'name'}}, - out: {inline: true} -}).results; + mapreduce: 'mr_index3', + map: m, + reduce: r, + query: {name: {$gt: 'name'}}, + out: {inline: true} + }).results; assert.eq([{"_id": "cat", "value": 3}, {"_id": "dog", "value": 2}, {"_id": "mouse", "value": 1}], a1, @@ -41,20 +37,16 @@ assert.eq(a1, a3, "A3"); t.ensureIndex({name: 1, tags: 1}); b1 = db.runCommand({mapreduce: 'mr_index3', map: m, reduce: r, out: {inline: true}}).results; -b2 = db.runCommand({ - mapreduce: 'mr_index3', - map: m, - reduce: r, - query: {name: 'name1'}, - out: {inline: true} -}).results; +b2 = db.runCommand( + {mapreduce: 'mr_index3', map: m, reduce: r, query: {name: 'name1'}, out: {inline: true}}) + .results; b3 = db.runCommand({ - mapreduce: 'mr_index3', - map: m, - reduce: r, - query: {name: {$gt: 'name'}}, - out: {inline: true} -}).results; + mapreduce: 'mr_index3', + map: m, + reduce: r, + query: {name: {$gt: 'name'}}, + out: {inline: true} + }).results; assert.eq(a1, b1, "AB1"); assert.eq(a2, b2, "AB2"); diff --git a/jstests/core/mr_killop.js b/jstests/core/mr_killop.js index 52865eacbe4..78e98f0bcaa 100644 --- a/jstests/core/mr_killop.js +++ b/jstests/core/mr_killop.js @@ -51,12 +51,7 @@ function testOne(map, reduce, finalize, scope, childLoop, wait) { t.save({a: 1}); t.save({a: 1}); - spec = { - mapreduce: "jstests_mr_killop", - out: "jstests_mr_killop_out", - map: map, - reduce: reduce - }; + spec = {mapreduce: "jstests_mr_killop", out: "jstests_mr_killop_out", map: map, reduce: reduce}; if (finalize) { spec["finalize"] = finalize; } diff --git a/jstests/core/mr_mutable_properties.js b/jstests/core/mr_mutable_properties.js index 12c52385275..84066bf76c0 100644 --- a/jstests/core/mr_mutable_properties.js +++ b/jstests/core/mr_mutable_properties.js @@ -8,28 +8,20 @@ collection.insert({a: 1}); var map = function() { // set property on receiver - this.feed = { - beef: 1 - }; + this.feed = {beef: 1}; // modify property on receiever - this.a = { - cake: 1 - }; + this.a = {cake: 1}; emit(this._id, this.feed); emit(this._id, this.a); }; var reduce = function(key, values) { // set property on receiver - this.feed = { - beat: 1 - }; + this.feed = {beat: 1}; // set property on key arg - key.fed = { - mochi: 1 - }; + key.fed = {mochi: 1}; // push properties onto values array arg values.push(this.feed); @@ -39,21 +31,15 @@ var reduce = function(key, values) { values.forEach(function(val) { val.mod = 1; }); - return { - food: values - }; + return {food: values}; }; var finalize = function(key, values) { // set property on receiver - this.feed = { - ice: 1 - }; + this.feed = {ice: 1}; // set property on key arg - key.fed = { - cream: 1 - }; + key.fed = {cream: 1}; // push properties onto values array arg printjson(values); diff --git a/jstests/core/mr_stored.js b/jstests/core/mr_stored.js index 63fa301e66d..5969638b8b9 100644 --- a/jstests/core/mr_stored.js +++ b/jstests/core/mr_stored.js @@ -22,10 +22,7 @@ r = function(k, v) { total += v[i].stats[j]; } } - return { - stats: stats, - total: total - }; + return {stats: stats, total: total}; }; // Test that map reduce works with stored javascript diff --git a/jstests/core/nestedarr1.js b/jstests/core/nestedarr1.js index 98ddc2193ea..720c1c27821 100644 --- a/jstests/core/nestedarr1.js +++ b/jstests/core/nestedarr1.js @@ -3,13 +3,9 @@ function makeNestArr(depth) { if (depth == 1) { - return { - a: [depth] - }; + return {a: [depth]}; } else { - return { - a: [makeNestArr(depth - 1)] - }; + return {a: [makeNestArr(depth - 1)]}; } } diff --git a/jstests/core/nestedobj1.js b/jstests/core/nestedobj1.js index 97b9460da6f..379224c1775 100644 --- a/jstests/core/nestedobj1.js +++ b/jstests/core/nestedobj1.js @@ -1,14 +1,10 @@ // SERVER-5127, SERVER-5036 function makeNestObj(depth) { - toret = { - a: 1 - }; + toret = {a: 1}; for (i = 1; i < depth; i++) { - toret = { - a: toret - }; + toret = {a: toret}; } return toret; diff --git a/jstests/core/nin.js b/jstests/core/nin.js index d6cd78ee7a4..e7bb66bed93 100644 --- a/jstests/core/nin.js +++ b/jstests/core/nin.js @@ -3,13 +3,9 @@ t.drop(); function checkEqual(name, key, value) { var o = {}; - o[key] = { - $in: [value] - }; + o[key] = {$in: [value]}; var i = t.find(o).count(); - o[key] = { - $nin: [value] - }; + o[key] = {$nin: [value]}; var n = t.find(o).count(); assert.eq(t.find().count(), diff --git a/jstests/core/not3.js b/jstests/core/not3.js index 9699f3838d1..9f3014f2c1a 100644 --- a/jstests/core/not3.js +++ b/jstests/core/not3.js @@ -9,15 +9,11 @@ t.save({_id: 0, arr: [1, 2, 3]}); t.save({_id: 1, arr: [10, 11]}); // Case 1: simple $ne over array field. -var case1 = { - arr: {$ne: 3} -}; +var case1 = {arr: {$ne: 3}}; assert.eq(1, t.find(case1).itcount(), "Case 1: wrong number of results"); assert.eq(1, t.findOne(case1)._id, "Case 1: wrong _id"); // Case 2: simple $not over array field. -var case2 = { - arr: {$not: {$gt: 6}} -}; +var case2 = {arr: {$not: {$gt: 6}}}; assert.eq(1, t.find(case2).itcount(), "Case 2: wrong number of results"); assert.eq(0, t.findOne(case2)._id, "Case 2: wrong _id"); diff --git a/jstests/core/or1.js b/jstests/core/or1.js index 0552524eb4c..e7c417800b6 100644 --- a/jstests/core/or1.js +++ b/jstests/core/or1.js @@ -41,14 +41,15 @@ doTest = function() { checkArrs([{_id: 0, a: 1}, {_id: 4, a: 1, b: 1}, {_id: 5, a: 1, b: 2}], a1); a1b2 = t.find({$or: [{a: 1}, {b: 2}]}).toArray(); - checkArrs([ - {_id: 0, a: 1}, - {_id: 3, b: 2}, - {_id: 4, a: 1, b: 1}, - {_id: 5, a: 1, b: 2}, - {_id: 7, a: 2, b: 2} - ], - a1b2); + checkArrs( + [ + {_id: 0, a: 1}, + {_id: 3, b: 2}, + {_id: 4, a: 1, b: 1}, + {_id: 5, a: 1, b: 2}, + {_id: 7, a: 2, b: 2} + ], + a1b2); t.drop(); t.save({a: [0, 1], b: [0, 1]}); diff --git a/jstests/core/or_inexact.js b/jstests/core/or_inexact.js index 8c9db1cc7ba..3e7e374d7f5 100644 --- a/jstests/core/or_inexact.js +++ b/jstests/core/or_inexact.js @@ -190,8 +190,8 @@ t.drop(); t.ensureIndex({"a.b": 1}); t.insert({_id: 0, a: [{b: 1}, {b: 2}]}); t.insert({_id: 1, a: [{b: 2}, {b: 4}]}); -cursor = t.find( - {"a.b": 2, $or: [{a: {$elemMatch: {b: {$lte: 1}}}}, {a: {$elemMatch: {b: {$gte: 4}}}}]}); +cursor = + t.find({"a.b": 2, $or: [{a: {$elemMatch: {b: {$lte: 1}}}}, {a: {$elemMatch: {b: {$gte: 4}}}}]}); assert.eq(2, cursor.itcount(), "case 14"); // Case 15: $or below $elemMatch. diff --git a/jstests/core/orc.js b/jstests/core/orc.js index 7d686972898..c68c6859651 100644 --- a/jstests/core/orc.js +++ b/jstests/core/orc.js @@ -22,24 +22,22 @@ t.ensureIndex({a: -1, b: 1, c: 1}); // sanity test t.save({a: null, b: 4, c: 4}); -assert.eq(1, - t.count({ - $or: [ - {a: null, b: {$gte: 0, $lte: 5}, c: {$gte: 0, $lte: 5}}, - {a: null, b: {$gte: 3, $lte: 8}, c: {$gte: 3, $lte: 8}} - ] - })); +assert.eq(1, t.count({ + $or: [ + {a: null, b: {$gte: 0, $lte: 5}, c: {$gte: 0, $lte: 5}}, + {a: null, b: {$gte: 3, $lte: 8}, c: {$gte: 3, $lte: 8}} + ] +})); // from here on is SERVER-2245 t.remove({}); t.save({b: 4, c: 4}); -assert.eq(1, - t.count({ - $or: [ - {a: null, b: {$gte: 0, $lte: 5}, c: {$gte: 0, $lte: 5}}, - {a: null, b: {$gte: 3, $lte: 8}, c: {$gte: 3, $lte: 8}} - ] - })); +assert.eq(1, t.count({ + $or: [ + {a: null, b: {$gte: 0, $lte: 5}, c: {$gte: 0, $lte: 5}}, + {a: null, b: {$gte: 3, $lte: 8}, c: {$gte: 3, $lte: 8}} + ] +})); // t.remove({}); // t.save( {a:[],b:4,c:4} ); diff --git a/jstests/core/ork.js b/jstests/core/ork.js index f367b6b4bad..7c9bc982776 100644 --- a/jstests/core/ork.js +++ b/jstests/core/ork.js @@ -7,17 +7,15 @@ t.ensureIndex({a: 1}); t.save({a: [1, 2], b: 5}); t.save({a: [2, 4], b: 5}); -assert.eq(2, - t.find({ - $or: [ - {a: 1, $and: [{$or: [{a: 2}, {a: 3}]}, {$or: [{b: 5}]}]}, - {a: 2, $or: [{a: 3}, {a: 4}]} - ] - }).itcount()); -assert.eq(1, - t.find({ - $or: [ - {a: 1, $and: [{$or: [{a: 2}, {a: 3}]}, {$or: [{b: 6}]}]}, - {a: 2, $or: [{a: 3}, {a: 4}]} - ] - }).itcount()); +assert.eq(2, t.find({ + $or: [ + {a: 1, $and: [{$or: [{a: 2}, {a: 3}]}, {$or: [{b: 5}]}]}, + {a: 2, $or: [{a: 3}, {a: 4}]} + ] + }).itcount()); +assert.eq(1, t.find({ + $or: [ + {a: 1, $and: [{$or: [{a: 2}, {a: 3}]}, {$or: [{b: 6}]}]}, + {a: 2, $or: [{a: 3}, {a: 4}]} + ] + }).itcount()); diff --git a/jstests/core/plan_cache_list_plans.js b/jstests/core/plan_cache_list_plans.js index b4be4ad46c4..7ca599483ff 100644 --- a/jstests/core/plan_cache_list_plans.js +++ b/jstests/core/plan_cache_list_plans.js @@ -5,11 +5,7 @@ t.drop(); // Utility function to list plans for a query. function getPlans(query, sort, projection) { - var key = { - query: query, - sort: sort, - projection: projection - }; + var key = {query: query, sort: sort, projection: projection}; var res = t.runCommand('planCacheListPlans', key); assert.commandWorked(res, 'planCacheListPlans(' + tojson(key, '', true) + ' failed'); assert(res.hasOwnProperty('plans'), @@ -32,9 +28,8 @@ assert.eq(0, 'planCacheListPlans should return empty results on unknown query shape'); // Create a cache entry. -assert.eq(1, - t.find({a: 1, b: 1}, {_id: 0, a: 1}).sort({a: -1}).itcount(), - 'unexpected document count'); +assert.eq( + 1, t.find({a: 1, b: 1}, {_id: 0, a: 1}).sort({a: -1}).itcount(), 'unexpected document count'); // Retrieve plans for valid cache entry. var plans = getPlans({a: 1, b: 1}, {a: -1}, {_id: 0, a: 1}); diff --git a/jstests/core/plan_cache_list_shapes.js b/jstests/core/plan_cache_list_shapes.js index 4711940870d..1c9ecdf9e1b 100644 --- a/jstests/core/plan_cache_list_shapes.js +++ b/jstests/core/plan_cache_list_shapes.js @@ -34,9 +34,8 @@ t.ensureIndex({a: 1}); t.ensureIndex({a: 1, b: 1}); // Run a query. -assert.eq(1, - t.find({a: 1, b: 1}, {_id: 1, a: 1}).sort({a: -1}).itcount(), - 'unexpected document count'); +assert.eq( + 1, t.find({a: 1, b: 1}, {_id: 1, a: 1}).sort({a: -1}).itcount(), 'unexpected document count'); // We now expect the two indices to be compared and a cache entry to exist. // Retrieve query shapes from the test collection diff --git a/jstests/core/plan_cache_shell_helpers.js b/jstests/core/plan_cache_shell_helpers.js index a61421afc7b..dc990b19dcc 100644 --- a/jstests/core/plan_cache_shell_helpers.js +++ b/jstests/core/plan_cache_shell_helpers.js @@ -16,11 +16,7 @@ function getShapes(collection) { } // Utility function to list plans for a query. function getPlans(query, sort, projection) { - var key = { - query: query, - sort: sort, - projection: projection - }; + var key = {query: query, sort: sort, projection: projection}; var res = t.runCommand('planCacheListPlans', key); assert.commandWorked(res, 'planCacheListPlans(' + tojson(key, '', true) + ' failed'); assert(res.hasOwnProperty('plans'), @@ -37,17 +33,9 @@ t.ensureIndex({a: 1}); t.ensureIndex({b: 1}); // Populate plan cache. -var queryB = { - a: {$gte: 199}, - b: -1 -}; -var projectionB = { - _id: 0, - b: 1 -}; -var sortC = { - c: -1 -}; +var queryB = {a: {$gte: 199}, b: -1}; +var projectionB = {_id: 0, b: 1}; +var sortC = {c: -1}; assert.eq(1, t.find(queryB, projectionB).sort(sortC).itcount(), 'unexpected document count'); assert.eq(1, t.find(queryB, projectionB).itcount(), 'unexpected document count'); assert.eq(1, t.find(queryB).sort(sortC).itcount(), 'unexpected document count'); @@ -124,11 +112,7 @@ assert.eq(getPlans(queryB, {}, {}), // projection: <projection>, // sort: <sort> // } -var shapeB = { - query: queryB, - projection: projectionB, - sort: sortC -}; +var shapeB = {query: queryB, projection: projectionB, sort: sortC}; assert.eq(getPlans(queryB, sortC, projectionB), planCache.getPlansByQuery(shapeB), 'collection.getPlanCache().getPlansByQuery() did not accept query shape object'); @@ -141,12 +125,13 @@ assert.eq(0, planCache.getPlansByQuery({query: queryB}).length, 'collection.getPlanCache.getPlansByQuery should return empty results on ' + 'incomplete query shape'); -assert.eq(0, - planCache.getPlansByQuery( - {query: queryB, sort: sortC, projection: projectionB, unknown_field: 1}) - .length, - 'collection.getPlanCache.getPlansByQuery should return empty results on ' + - 'invalid query shape'); +assert.eq( + 0, + planCache + .getPlansByQuery({query: queryB, sort: sortC, projection: projectionB, unknown_field: 1}) + .length, + 'collection.getPlanCache.getPlansByQuery should return empty results on ' + + 'invalid query shape'); // // collection.getPlanCache().clearPlansByQuery diff --git a/jstests/core/pop_server_13516.js b/jstests/core/pop_server_13516.js index 8d0bacbb3e5..008d0de79a1 100644 --- a/jstests/core/pop_server_13516.js +++ b/jstests/core/pop_server_13516.js @@ -4,10 +4,7 @@ var t = db.jstests_pop_server_13516; t.drop(); var id = NumberInt(0); -var object = { - _id: id, - data: [] -}; +var object = {_id: id, data: []}; for (var i = 0; i < 4096; i++) { object.data[i] = 0; diff --git a/jstests/core/profile1.js b/jstests/core/profile1.js index 67f4a53d2b9..b1024f6668c 100644 --- a/jstests/core/profile1.js +++ b/jstests/core/profile1.js @@ -87,12 +87,8 @@ resetProfile(2); db.profile1.drop(); - var q = { - _id: 5 - }; - var u = { - $inc: {x: 1} - }; + var q = {_id: 5}; + var u = {$inc: {x: 1}}; db.profile1.update(q, u); var r = profileCursor({ns: db.profile1.getFullName()}).sort({$natural: -1})[0]; assert.eq(q, r.query, "Y1: " + tojson(r)); diff --git a/jstests/core/profile_count.js b/jstests/core/profile_count.js index 09ba6520828..d79fb94df85 100644 --- a/jstests/core/profile_count.js +++ b/jstests/core/profile_count.js @@ -44,9 +44,7 @@ assert.writeOK(coll.insert({a: i})); } - var query = { - a: {$gte: 5} - }; + var query = {a: {$gte: 5}}; assert.eq(5, coll.count(query)); profileObj = getLatestProfilerEntry(testDB); @@ -62,9 +60,7 @@ } assert.commandWorked(coll.createIndex({a: 1})); - query = { - a: {$gte: 5} - }; + query = {a: {$gte: 5}}; assert.eq(5, coll.count(query)); profileObj = getLatestProfilerEntry(testDB); diff --git a/jstests/core/profile_insert.js b/jstests/core/profile_insert.js index 75a44fcb4e9..e49699a9d11 100644 --- a/jstests/core/profile_insert.js +++ b/jstests/core/profile_insert.js @@ -17,9 +17,7 @@ // // Test single insert. // - var doc = { - _id: 1 - }; + var doc = {_id: 1}; var result = coll.insert(doc); if (isWriteCommand) { assert.writeOK(result); @@ -76,9 +74,7 @@ // Test insert options. // coll.drop(); - doc = { - _id: 1 - }; + doc = {_id: 1}; var wtimeout = 60000; assert.writeOK(coll.insert(doc, {writeConcern: {w: 1, wtimeout: wtimeout}, ordered: false})); diff --git a/jstests/core/push_sort.js b/jstests/core/push_sort.js index 0e407d969ba..b9676f6c963 100644 --- a/jstests/core/push_sort.js +++ b/jstests/core/push_sort.js @@ -53,10 +53,7 @@ assert.eq([{a: {b: 2}}, {a: {b: 3}}], t.findOne({_id: 7}).x); // // $push with $sort should not push a "$sort" field -var doc8 = { - _id: 8, - x: [{a: 1}, {a: 2}] -}; +var doc8 = {_id: 8, x: [{a: 1}, {a: 2}]}; t.save(doc8); var res = t.update({_id: 8}, {$push: {x: {$sort: {a: -1}}}}); assert.writeError(res); diff --git a/jstests/core/ref.js b/jstests/core/ref.js index 02c4cb92a07..33d83738cd2 100644 --- a/jstests/core/ref.js +++ b/jstests/core/ref.js @@ -4,10 +4,7 @@ db.otherthings.drop(); db.things.drop(); -var other = { - s: "other thing", - n: 1 -}; +var other = {s: "other thing", n: 1}; db.otherthings.save(other); db.things.save({name: "abc"}); diff --git a/jstests/core/ref3.js b/jstests/core/ref3.js index 929e4152daf..4406863d899 100644 --- a/jstests/core/ref3.js +++ b/jstests/core/ref3.js @@ -4,10 +4,7 @@ db.otherthings3.drop(); db.things3.drop(); -var other = { - s: "other thing", - n: 1 -}; +var other = {s: "other thing", n: 1}; db.otherthings3.save(other); db.things3.save({name: "abc"}); diff --git a/jstests/core/ref4.js b/jstests/core/ref4.js index 07796d1e96a..882253f3883 100644 --- a/jstests/core/ref4.js +++ b/jstests/core/ref4.js @@ -5,10 +5,7 @@ b = db.ref4b; a.drop(); b.drop(); -var other = { - s: "other thing", - n: 17 -}; +var other = {s: "other thing", n: 17}; b.save(other); a.save({name: "abc", others: [new DBRef("ref4b", other._id), new DBPointer("ref4b", other._id)]}); diff --git a/jstests/core/regex2.js b/jstests/core/regex2.js index 80dec55f184..fe933892834 100644 --- a/jstests/core/regex2.js +++ b/jstests/core/regex2.js @@ -29,9 +29,8 @@ assert.eq(1, t.find({a: a}).count(), "C B"); assert.eq(1, t.find({a: b}).count(), "C C"); assert.eq(1, t.find({a: new RegExp(a)}).count(), "C D"); assert.eq(1, t.find({a: new RegExp(b)}).count(), "C E"); -assert.eq(2, - t.find({a: new RegExp(a, "i")}).count(), - "C F is spidermonkey built with UTF-8 support?"); +assert.eq( + 2, t.find({a: new RegExp(a, "i")}).count(), "C F is spidermonkey built with UTF-8 support?"); // same tests as above but using {$regex: "a|b", $options: "imx"} syntax. t.drop(); diff --git a/jstests/core/regex3.js b/jstests/core/regex3.js index bc1623cecea..23b7f3c69cc 100644 --- a/jstests/core/regex3.js +++ b/jstests/core/regex3.js @@ -8,9 +8,8 @@ t.save({name: "bob"}); t.save({name: "aaron"}); assert.eq(2, t.find({name: /^e.*/}).itcount(), "no index count"); -assert.eq(4, - t.find({name: /^e.*/}).explain(true).executionStats.totalDocsExamined, - "no index explain"); +assert.eq( + 4, t.find({name: /^e.*/}).explain(true).executionStats.totalDocsExamined, "no index explain"); t.ensureIndex({name: 1}); assert.eq(2, t.find({name: /^e.*/}).itcount(), "index count"); assert.eq(2, diff --git a/jstests/core/regex4.js b/jstests/core/regex4.js index 112375e2e09..131f93bcc26 100644 --- a/jstests/core/regex4.js +++ b/jstests/core/regex4.js @@ -8,9 +8,8 @@ t.save({name: "bob"}); t.save({name: "aaron"}); assert.eq(2, t.find({name: /^e.*/}).count(), "no index count"); -assert.eq(4, - t.find({name: /^e.*/}).explain(true).executionStats.totalDocsExamined, - "no index explain"); +assert.eq( + 4, t.find({name: /^e.*/}).explain(true).executionStats.totalDocsExamined, "no index explain"); // assert.eq( 2 , t.find( { name : { $ne : /^e.*/ } } ).count() , "no index count ne" ); // // SERVER-251 diff --git a/jstests/core/regex6.js b/jstests/core/regex6.js index 7b9ed1910ed..b7e90664c4d 100644 --- a/jstests/core/regex6.js +++ b/jstests/core/regex6.js @@ -11,30 +11,24 @@ t.save({name: "[with]some?symbols"}); t.ensureIndex({name: 1}); assert.eq(0, t.find({name: /^\//}).count(), "index count"); -assert.eq(1, - t.find({name: /^\//}).explain(true).executionStats.totalKeysExamined, - "index explain 1"); -assert.eq(0, - t.find({name: /^é/}).explain(true).executionStats.totalKeysExamined, - "index explain 2"); -assert.eq(0, - t.find({name: /^\é/}).explain(true).executionStats.totalKeysExamined, - "index explain 3"); -assert.eq(1, - t.find({name: /^\./}).explain(true).executionStats.totalKeysExamined, - "index explain 4"); -assert.eq(5, - t.find({name: /^./}).explain(true).executionStats.totalKeysExamined, - "index explain 5"); +assert.eq( + 1, t.find({name: /^\//}).explain(true).executionStats.totalKeysExamined, "index explain 1"); +assert.eq( + 0, t.find({name: /^é/}).explain(true).executionStats.totalKeysExamined, "index explain 2"); +assert.eq( + 0, t.find({name: /^\é/}).explain(true).executionStats.totalKeysExamined, "index explain 3"); +assert.eq( + 1, t.find({name: /^\./}).explain(true).executionStats.totalKeysExamined, "index explain 4"); +assert.eq( + 5, t.find({name: /^./}).explain(true).executionStats.totalKeysExamined, "index explain 5"); // SERVER-2862 assert.eq(0, t.find({name: /^\Qblah\E/}).count(), "index explain 6"); assert.eq(1, t.find({name: /^\Qblah\E/}).explain(true).executionStats.totalKeysExamined, "index explain 6"); -assert.eq(1, - t.find({name: /^blah/}).explain(true).executionStats.totalKeysExamined, - "index explain 6"); +assert.eq( + 1, t.find({name: /^blah/}).explain(true).executionStats.totalKeysExamined, "index explain 6"); assert.eq(1, t.find({name: /^\Q[\Ewi\Qth]some?s\Eym/}).count(), "index count 2"); assert.eq(2, t.find({name: /^\Q[\Ewi\Qth]some?s\Eym/}).explain(true).executionStats.totalKeysExamined, @@ -43,13 +37,11 @@ assert.eq(2, t.find({name: /^bob/}).explain(true).executionStats.totalKeysExamined, "index explain 6"); // proof executionStats.totalKeysExamined == count+1 -assert.eq(1, - t.find({name: {$regex: "^e", $gte: "emily"}}) - .explain(true) - .executionStats.totalKeysExamined, - "ie7"); -assert.eq(1, - t.find({name: {$gt: "a", $regex: "^emily"}}) - .explain(true) - .executionStats.totalKeysExamined, - "ie7"); +assert.eq( + 1, + t.find({name: {$regex: "^e", $gte: "emily"}}).explain(true).executionStats.totalKeysExamined, + "ie7"); +assert.eq( + 1, + t.find({name: {$gt: "a", $regex: "^emily"}}).explain(true).executionStats.totalKeysExamined, + "ie7"); diff --git a/jstests/core/remove7.js b/jstests/core/remove7.js index ef5500fa1fa..9c78b24eefa 100644 --- a/jstests/core/remove7.js +++ b/jstests/core/remove7.js @@ -22,9 +22,7 @@ t.ensureIndex({tags: 1}); for (i = 0; i < 200; i++) { for (var j = 0; j < 10; j++) t.save({tags: getTags(100)}); - var q = { - tags: {$in: getTags(10)} - }; + var q = {tags: {$in: getTags(10)}}; var before = t.find(q).count(); var res = t.remove(q); var after = t.find(q).count(); diff --git a/jstests/core/rename4.js b/jstests/core/rename4.js index 904709175f9..185193deaa9 100644 --- a/jstests/core/rename4.js +++ b/jstests/core/rename4.js @@ -101,9 +101,8 @@ good({aa: 1, b: 2}, {$rename: {z: 'c'}, $set: {b: 5}}, {aa: 1, b: 5}); good({a: {z: 1, b: 1}}, {$rename: {'a.b': 'a.c'}}, {a: {c: 1, z: 1}}); good({a: {z: 1, tomato: 1}}, {$rename: {'a.tomato': 'a.potato'}}, {a: {potato: 1, z: 1}}); good({a: {z: 1, b: 1, c: 1}}, {$rename: {'a.b': 'a.c'}}, {a: {c: 1, z: 1}}); -good({a: {z: 1, tomato: 1, potato: 1}}, - {$rename: {'a.tomato': 'a.potato'}}, - {a: {potato: 1, z: 1}}); +good( + {a: {z: 1, tomato: 1, potato: 1}}, {$rename: {'a.tomato': 'a.potato'}}, {a: {potato: 1, z: 1}}); good({a: {z: 1, b: 1}}, {$rename: {'a.b': 'a.cc'}}, {a: {cc: 1, z: 1}}); good({a: {z: 1, b: 1, c: 1}}, {$rename: {'a.b': 'aa.c'}}, {a: {c: 1, z: 1}, aa: {c: 1}}); diff --git a/jstests/core/repair_database.js b/jstests/core/repair_database.js index 45f936b022a..2005a7bf344 100644 --- a/jstests/core/repair_database.js +++ b/jstests/core/repair_database.js @@ -13,10 +13,7 @@ mydb.dropDatabase(); var myColl = mydb.a; // 2 -var doc = { - _id: 1, - a: "hello world" -}; +var doc = {_id: 1, a: "hello world"}; myColl.insert(doc); myColl.ensureIndex({a: 1}); mydb.repairDatabase(); diff --git a/jstests/core/return_key.js b/jstests/core/return_key.js index b39764846d4..3692521f58c 100644 --- a/jstests/core/return_key.js +++ b/jstests/core/return_key.js @@ -73,10 +73,9 @@ load("jstests/libs/analyze_plan.js"); .sort({b: 1}) .returnKey() .toArray(); - assert.eq(results, - [ - {a: 3, c: {'': 1}, d: {'': 1}}, - {a: 2, c: {'': 2}, d: {'': 2}}, - {a: 1, c: {'': 3}, d: {'': 3}} - ]); + assert.eq(results, [ + {a: 3, c: {'': 1}, d: {'': 1}}, + {a: 2, c: {'': 2}, d: {'': 2}}, + {a: 1, c: {'': 3}, d: {'': 3}} + ]); })(); diff --git a/jstests/core/role_management_helpers.js b/jstests/core/role_management_helpers.js index fa25d8a2d57..b47d87e5533 100644 --- a/jstests/core/role_management_helpers.js +++ b/jstests/core/role_management_helpers.js @@ -106,12 +106,10 @@ function assertHasPrivilege(privilegeArray, privilege) { assertHasRole(roleObj.roles, "roleC", db.getName()); // Privileges on the same resource get collapsed - db.grantPrivilegesToRole( - "roleA", - [ - {resource: {db: db.getName(), collection: ""}, actions: ['dropDatabase']}, - {resource: {db: db.getName(), collection: "foo"}, actions: ['insert']} - ]); + db.grantPrivilegesToRole("roleA", [ + {resource: {db: db.getName(), collection: ""}, actions: ['dropDatabase']}, + {resource: {db: db.getName(), collection: "foo"}, actions: ['insert']} + ]); roleObj = db.getRole("roleA", {showPrivileges: true}); assert.eq(0, roleObj.roles.length); assert.eq(2, roleObj.privileges.length); @@ -122,12 +120,10 @@ function assertHasPrivilege(privilegeArray, privilege) { {resource: {db: db.getName(), collection: ""}, actions: ['dropDatabase']}); // Update role - db.updateRole( - "roleA", - { - roles: ['roleB'], - privileges: [{resource: {db: db.getName(), collection: "foo"}, actions: ['find']}] - }); + db.updateRole("roleA", { + roles: ['roleB'], + privileges: [{resource: {db: db.getName(), collection: "foo"}, actions: ['find']}] + }); roleObj = db.getRole("roleA", {showPrivileges: true}); assert.eq(1, roleObj.roles.length); assertHasRole(roleObj.roles, "roleB", db.getName()); diff --git a/jstests/core/set_param1.js b/jstests/core/set_param1.js index 2df37442518..b0df18bccd3 100644 --- a/jstests/core/set_param1.js +++ b/jstests/core/set_param1.js @@ -28,14 +28,12 @@ assert.neq(undefined, assert.commandFailed(db.adminCommand({"setParameter": 1, logComponentVerbosity: "not an object"})); // Non-numeric verbosity for component should be rejected. -assert.commandFailed(db.adminCommand({ - "setParameter": 1, - logComponentVerbosity: {storage: {journal: {verbosity: "not a number"}}} -})); +assert.commandFailed(db.adminCommand( + {"setParameter": 1, logComponentVerbosity: {storage: {journal: {verbosity: "not a number"}}}})); // Invalid component shall be rejected -assert.commandFailed(db.adminCommand( - {"setParameter": 1, logComponentVerbosity: {NoSuchComponent: {verbosity: 2}}})); +assert.commandFailed( + db.adminCommand({"setParameter": 1, logComponentVerbosity: {NoSuchComponent: {verbosity: 2}}})); // Set multiple component log levels at once. (function() { diff --git a/jstests/core/sort3.js b/jstests/core/sort3.js index bfc1ee5134c..933f16da6cb 100644 --- a/jstests/core/sort3.js +++ b/jstests/core/sort3.js @@ -5,16 +5,13 @@ t.save({a: 1}); t.save({a: 5}); t.save({a: 3}); -assert.eq("1,5,3", - t.find().toArray().map(function(z) { - return z.a; - })); +assert.eq("1,5,3", t.find().toArray().map(function(z) { + return z.a; +})); -assert.eq("1,3,5", - t.find().sort({a: 1}).toArray().map(function(z) { - return z.a; - })); -assert.eq("5,3,1", - t.find().sort({a: -1}).toArray().map(function(z) { - return z.a; - })); +assert.eq("1,3,5", t.find().sort({a: 1}).toArray().map(function(z) { + return z.a; +})); +assert.eq("5,3,1", t.find().sort({a: -1}).toArray().map(function(z) { + return z.a; +})); diff --git a/jstests/core/sort5.js b/jstests/core/sort5.js index 399c9fb4e28..05fe781ae32 100644 --- a/jstests/core/sort5.js +++ b/jstests/core/sort5.js @@ -9,37 +9,29 @@ t.save({_id: 9, x: 4, y: {a: 9, b: 3}}); // test compound sorting assert.eq([4, 2, 3, 1], - t.find() - .sort({"y.b": 1, "y.a": -1}) - .map(function(z) { - return z.x; - }), + t.find().sort({"y.b": 1, "y.a": -1}).map(function(z) { + return z.x; + }), "A no index"); t.ensureIndex({"y.b": 1, "y.a": -1}); assert.eq([4, 2, 3, 1], - t.find() - .sort({"y.b": 1, "y.a": -1}) - .map(function(z) { - return z.x; - }), + t.find().sort({"y.b": 1, "y.a": -1}).map(function(z) { + return z.x; + }), "A index"); assert(t.validate().valid, "A valid"); // test sorting on compound key involving _id assert.eq([4, 2, 3, 1], - t.find() - .sort({"y.b": 1, _id: -1}) - .map(function(z) { - return z.x; - }), + t.find().sort({"y.b": 1, _id: -1}).map(function(z) { + return z.x; + }), "B no index"); t.ensureIndex({"y.b": 1, "_id": -1}); assert.eq([4, 2, 3, 1], - t.find() - .sort({"y.b": 1, _id: -1}) - .map(function(z) { - return z.x; - }), + t.find().sort({"y.b": 1, _id: -1}).map(function(z) { + return z.x; + }), "B index"); assert(t.validate().valid, "B valid"); diff --git a/jstests/core/sortk.js b/jstests/core/sortk.js index 7ecb86fa6df..76c381681eb 100644 --- a/jstests/core/sortk.js +++ b/jstests/core/sortk.js @@ -17,17 +17,10 @@ resetCollection(); t.ensureIndex({a: 1, b: 1}); function simpleQuery(extraFields, sort, hint) { - query = { - a: {$in: [1, 2]} - }; + query = {a: {$in: [1, 2]}}; Object.extend(query, extraFields); - sort = sort || { - b: 1 - }; - hint = hint || { - a: 1, - b: 1 - }; + sort = sort || {b: 1}; + hint = hint || {a: 1, b: 1}; return t.find(query).sort(sort).hint(hint); } @@ -133,9 +126,7 @@ assert.eq(0, andEqInQueryWithLimit(-2)[0].c); assert.eq(1, andEqInQueryWithLimit(-2)[1].c); function inQueryWithLimit(limit, sort) { - sort = sort || { - b: 1 - }; + sort = sort || {b: 1}; return t.find({a: {$in: [0, 1]}}).sort(sort).hint({a: 1, b: 1, c: 1}).limit(limit); } diff --git a/jstests/core/splitvector.js b/jstests/core/splitvector.js index 233911d29c6..9ba62e2df83 100644 --- a/jstests/core/splitvector.js +++ b/jstests/core/splitvector.js @@ -62,17 +62,17 @@ resetCollection(); // Case 1: missing parameters assert.eq(false, db.runCommand({splitVector: "test.jstests_splitvector"}).ok, "1a"); -assert.eq(false, - db.runCommand({splitVector: "test.jstests_splitvector", maxChunkSize: 1}).ok, - "1b"); +assert.eq( + false, db.runCommand({splitVector: "test.jstests_splitvector", maxChunkSize: 1}).ok, "1b"); // ------------------------- // Case 2: missing index -assert.eq(false, - db.runCommand( - {splitVector: "test.jstests_splitvector", keyPattern: {x: 1}, maxChunkSize: 1}).ok, - "2"); +assert.eq( + false, + db.runCommand({splitVector: "test.jstests_splitvector", keyPattern: {x: 1}, maxChunkSize: 1}) + .ok, + "2"); // ------------------------- // Case 3: empty collection diff --git a/jstests/core/stages_delete.js b/jstests/core/stages_delete.js index 1624b1fcc6a..f8e7380c75a 100644 --- a/jstests/core/stages_delete.js +++ b/jstests/core/stages_delete.js @@ -1,8 +1,6 @@ // Test basic delete stage functionality. var coll = db.stages_delete; -var collScanStage = { - cscan: {args: {direction: 1}, filter: {deleteMe: true}} -}; +var collScanStage = {cscan: {args: {direction: 1}, filter: {deleteMe: true}}}; var deleteStage; // Test delete stage with isMulti: true. diff --git a/jstests/core/stages_sort.js b/jstests/core/stages_sort.js index b6cb5a456af..6d25279fa27 100644 --- a/jstests/core/stages_sort.js +++ b/jstests/core/stages_sort.js @@ -25,9 +25,7 @@ if (false) { }; // Sort with foo ascending. - sort1 = { - sort: {args: {node: ixscan1, pattern: {foo: 1}}} - }; + sort1 = {sort: {args: {node: ixscan1, pattern: {foo: 1}}}}; res = db.runCommand({stageDebug: sort1}); assert.eq(res.ok, 1); assert.eq(res.results.length, 21); diff --git a/jstests/core/system_profile.js b/jstests/core/system_profile.js index 73d303a3277..09baf334290 100644 --- a/jstests/core/system_profile.js +++ b/jstests/core/system_profile.js @@ -26,25 +26,24 @@ assert.writeError(testDB.system.profile.remove({})); // Using findAndModify to write to "system.profile" should fail. assert.commandWorked(testDB.dropDatabase()); assert.commandWorked(testDB.createCollection("system.profile")); -assert.commandFailed(testDB.system.profile.runCommand("findAndModify", - {query: {}, update: {a: 1}})); -assert.commandFailed(testDB.system.profile.runCommand("findAndModify", - {query: {}, update: {a: 1}, upsert: true})); +assert.commandFailed( + testDB.system.profile.runCommand("findAndModify", {query: {}, update: {a: 1}})); +assert.commandFailed( + testDB.system.profile.runCommand("findAndModify", {query: {}, update: {a: 1}, upsert: true})); assert.commandFailed(testDB.system.profile.runCommand("findAndModify", {query: {}, remove: true})); // Using mapReduce to write to "system.profile" should fail. assert.commandWorked(testDB.dropDatabase()); assert.writeOK(testDB.foo.insert({val: 1})); -assert.commandFailed(testDB.foo.runCommand("mapReduce", - { - map: function() { - emit(0, this.val); - }, - reduce: function(id, values) { - return Array.sum(values); - }, - out: "system.profile" - })); +assert.commandFailed(testDB.foo.runCommand("mapReduce", { + map: function() { + emit(0, this.val); + }, + reduce: function(id, values) { + return Array.sum(values); + }, + out: "system.profile" +})); // Using aggregate to write to "system.profile" should fail. assert.commandWorked(testDB.dropDatabase()); diff --git a/jstests/core/update_find_and_modify_id.js b/jstests/core/update_find_and_modify_id.js index a75a5595451..ca565cb0e8c 100644 --- a/jstests/core/update_find_and_modify_id.js +++ b/jstests/core/update_find_and_modify_id.js @@ -2,10 +2,7 @@ // an _id in the update document, as long as the _id will not be modified var t = db.jstests_server4516; -var startingDoc = { - _id: 1, - a: 1 -}; +var startingDoc = {_id: 1, a: 1}; function prepare() { t.drop(); diff --git a/jstests/core/update_min_max_examples.js b/jstests/core/update_min_max_examples.js index a8a86f22986..7bcb6197f93 100644 --- a/jstests/core/update_min_max_examples.js +++ b/jstests/core/update_min_max_examples.js @@ -46,10 +46,7 @@ assert.writeOK(res); assert.eq(coll.findOne({_id: 6}).a, 1e-15); // $max with positional operator -var insertdoc = { - _id: 7, - y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}] -}; +var insertdoc = {_id: 7, y: [{a: 2}, {a: 6}, {a: [9, 1, 1]}]}; coll.insert(insertdoc); res = coll.update({_id: 7, "y.a": 6}, {$max: {"y.$.a": 7}}); assert.writeOK(res); diff --git a/jstests/core/update_server-12848.js b/jstests/core/update_server-12848.js index c33e8dd9f62..0f86e0135b3 100644 --- a/jstests/core/update_server-12848.js +++ b/jstests/core/update_server-12848.js @@ -8,10 +8,7 @@ var res; var t = db.update_server_12848; t.drop(); -var orig = { - "_id": 1, - "a": [1, []] -}; +var orig = {"_id": 1, "a": [1, []]}; res = t.insert(orig); assert.writeOK(res, "insert"); assert.eq(orig, t.findOne()); @@ -19,8 +16,5 @@ assert.eq(orig, t.findOne()); res = t.update({"_id": 1}, {$addToSet: {"a.1": 1}}); assert.writeOK(res, "update"); -var updated = { - "_id": 1, - "a": [1, [1]] -}; +var updated = {"_id": 1, "a": [1, [1]]}; assert.eq(updated, t.findOne()); diff --git a/jstests/core/upsert_fields.js b/jstests/core/upsert_fields.js index ae385980b1b..910ae6d3e11 100644 --- a/jstests/core/upsert_fields.js +++ b/jstests/core/upsert_fields.js @@ -60,13 +60,9 @@ for (var i = 0; i < 3; i++) { // $op style if (i == 1) - expr = { - $set: {a: 1} - }; + expr = {$set: {a: 1}}; if (i == 2) - expr = { - $setOnInsert: {a: 1} - }; + expr = {$setOnInsert: {a: 1}}; var isReplStyle = i == 0; @@ -135,13 +131,9 @@ for (var i = 0; i < 3; i++) { // $op style if (i == 1) - expr = { - $set: {a: 1} - }; + expr = {$set: {a: 1}}; if (i == 2) - expr = { - $setOnInsert: {a: 1} - }; + expr = {$setOnInsert: {a: 1}}; var isReplStyle = i == 0; @@ -187,9 +179,7 @@ for (var i = 0; i < 3; i++) { } // nested field extraction - var docValue = isReplStyle ? undefined : { - x: 1 - }; + var docValue = isReplStyle ? undefined : {x: 1}; assert.docEq(docValue, upsertedXVal({"x.x": 1}, expr)); assert.docEq(docValue, upsertedXVal({"x.x": {$eq: 1}}, expr)); assert.docEq(docValue, upsertedXVal({"x.x": {$all: [1]}}, expr)); diff --git a/jstests/core/validate_user_documents.js b/jstests/core/validate_user_documents.js index 9c12e6075a7..676c47a301f 100644 --- a/jstests/core/validate_user_documents.js +++ b/jstests/core/validate_user_documents.js @@ -34,8 +34,7 @@ assert.commandWorked(mydb.runCommand({createUser: "spencer", pwd: "password", ro assert.commandWorked(mydb.runCommand({ createUser: "andy", pwd: "password", - roles: - [{role: "dbAdmin", db: "validate_user_documents", hasRole: true, canDelegate: false}] + roles: [{role: "dbAdmin", db: "validate_user_documents", hasRole: true, canDelegate: false}] })); // Non-existent role; insert should fail diff --git a/jstests/core/where1.js b/jstests/core/where1.js index 85466901016..53441580b90 100644 --- a/jstests/core/where1.js +++ b/jstests/core/where1.js @@ -8,8 +8,8 @@ t.save({a: 3}); assert.eq(1, t.find(function() { - return this.a == 2; - }).length(), + return this.a == 2; + }).length(), "A"); assert.eq(1, t.find({$where: "return this.a == 2"}).toArray().length, "B"); diff --git a/jstests/core/where3.js b/jstests/core/where3.js index 633276489a5..e26b36ffcf4 100644 --- a/jstests/core/where3.js +++ b/jstests/core/where3.js @@ -7,8 +7,8 @@ t.save({returned_date: 6}); assert.eq(1, t.find(function() { - return this.returned_date == 5; - }).count(), + return this.returned_date == 5; + }).count(), "A"); assert.eq(1, t.find({$where: "return this.returned_date == 5;"}).count(), "B"); assert.eq(1, t.find({$where: "this.returned_date == 5;"}).count(), "C"); diff --git a/jstests/core/where4.js b/jstests/core/where4.js index 612dba59e67..3db37ae6fe5 100644 --- a/jstests/core/where4.js +++ b/jstests/core/where4.js @@ -5,15 +5,14 @@ myDB.dropDatabase(); assert.writeOK(myDB.where4.insert({x: 1, y: 1})); assert.writeOK(myDB.where4.insert({x: 2, y: 1})); -assert.writeOK(myDB.where4.update( - { - $where: function() { - return this.x == 1; - } - }, - {$inc: {y: 1}}, - false, - true)); +assert.writeOK(myDB.where4.update({ + $where: function() { + return this.x == 1; + } +}, + {$inc: {y: 1}}, + false, + true)); assert.eq(2, myDB.where4.findOne({x: 1}).y); assert.eq(1, myDB.where4.findOne({x: 2}).y); |