diff options
author | Davis Haupt <davis.haupt@mongodb.com> | 2022-06-16 19:48:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-16 20:21:48 +0000 |
commit | 5113ee9b35acfa01f72a10ca761869bbab7b17cc (patch) | |
tree | fbe5a5756216a902e59661900b71fd6ac3845603 /jstests | |
parent | f4e6ef798a32582298186b70b09477175545b5ba (diff) | |
download | mongo-5113ee9b35acfa01f72a10ca761869bbab7b17cc.tar.gz |
SERVER-67337 add back code 16554 for type mismatch in $add
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/aggregation/accumulators/accumulator_js.js | 5 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server6570.js | 18 | ||||
-rw-r--r-- | jstests/libs/sbe_assert_error_override.js | 2 | ||||
-rw-r--r-- | jstests/sharding/error_propagation.js | 2 |
4 files changed, 15 insertions, 12 deletions
diff --git a/jstests/aggregation/accumulators/accumulator_js.js b/jstests/aggregation/accumulators/accumulator_js.js index 231fe309910..90460e2ce72 100644 --- a/jstests/aggregation/accumulators/accumulator_js.js +++ b/jstests/aggregation/accumulators/accumulator_js.js @@ -192,8 +192,9 @@ command.pipeline = [{ } } }]; -// ErrorCodes.TypeMismatch means "$add only supports numeric or date types" -assert.commandFailedWithCode(db.runCommand(command), ErrorCodes.TypeMismatch); +// ErrorCodes.TypeMismatch means "$add only supports numeric or date types". Code 16554 represented +// a type mismatch before 6.1 for this specific check. +assert.commandFailedWithCode(db.runCommand(command), [16554, ErrorCodes.TypeMismatch]); // Test that initArgs can have a different length per group. assert(db.accumulator_js.drop()); diff --git a/jstests/aggregation/bugs/server6570.js b/jstests/aggregation/bugs/server6570.js index a2c5952a09d..b12a83967ba 100644 --- a/jstests/aggregation/bugs/server6570.js +++ b/jstests/aggregation/bugs/server6570.js @@ -6,17 +6,19 @@ c = db.s6570; c.drop(); c.save({x: 17, y: "foo"}); +// 16554 was the code used instead of TypeMismatch before 6.1. assertErrorCode( - c, {$project: {string_fields: {$add: [3, "$y", 4, "$y"]}}}, ErrorCodes.TypeMismatch); + c, {$project: {string_fields: {$add: [3, "$y", 4, "$y"]}}}, [16554, ErrorCodes.TypeMismatch]); +assertErrorCode(c, + {$project: {number_fields: {$add: ["a", "$x", "b", "$x"]}}}, + [16554, ErrorCodes.TypeMismatch]); assertErrorCode( - c, {$project: {number_fields: {$add: ["a", "$x", "b", "$x"]}}}, ErrorCodes.TypeMismatch); + c, {$project: {all_strings: {$add: ["c", "$y", "d", "$y"]}}}, [16554, ErrorCodes.TypeMismatch]); assertErrorCode( - c, {$project: {all_strings: {$add: ["c", "$y", "d", "$y"]}}}, ErrorCodes.TypeMismatch); + c, {$project: {potpourri_1: {$add: [5, "$y", "e", "$x"]}}}, [16554, ErrorCodes.TypeMismatch]); assertErrorCode( - c, {$project: {potpourri_1: {$add: [5, "$y", "e", "$x"]}}}, ErrorCodes.TypeMismatch); + c, {$project: {potpourri_2: {$add: [6, "$x", "f", "$y"]}}}, [16554, ErrorCodes.TypeMismatch]); assertErrorCode( - c, {$project: {potpourri_2: {$add: [6, "$x", "f", "$y"]}}}, ErrorCodes.TypeMismatch); + c, {$project: {potpourri_3: {$add: ["g", "$y", 7, "$x"]}}}, [16554, ErrorCodes.TypeMismatch]); assertErrorCode( - c, {$project: {potpourri_3: {$add: ["g", "$y", 7, "$x"]}}}, ErrorCodes.TypeMismatch); -assertErrorCode( - c, {$project: {potpourri_4: {$add: ["h", "$x", 8, "$y"]}}}, ErrorCodes.TypeMismatch); + c, {$project: {potpourri_4: {$add: ["h", "$x", 8, "$y"]}}}, [16554, ErrorCodes.TypeMismatch]); diff --git a/jstests/libs/sbe_assert_error_override.js b/jstests/libs/sbe_assert_error_override.js index a8d17f8060b..35e40388a68 100644 --- a/jstests/libs/sbe_assert_error_override.js +++ b/jstests/libs/sbe_assert_error_override.js @@ -25,7 +25,7 @@ const equivalentErrorCodesList = [ [16006, 4997703, 4998202], [16007, 5066300], [16020, 5066300], - [ErrorCodes.TypeMismatch, 4974201, 4974203], + [16554, ErrorCodes.TypeMismatch, 4974201, 4974203], [16555, 5073102], [16608, 4848401], [16609, 5073101], diff --git a/jstests/sharding/error_propagation.js b/jstests/sharding/error_propagation.js index 357f2fe2b3c..1a74270f745 100644 --- a/jstests/sharding/error_propagation.js +++ b/jstests/sharding/error_propagation.js @@ -20,6 +20,6 @@ assert.commandWorked(db.foo.insert({a: [1, 2]}, {writeConcern: {w: 3}})); var res = db.runCommand( {aggregate: 'foo', pipeline: [{$project: {total: {'$add': ['$a', 1]}}}], cursor: {}}); -assert.commandFailedWithCode(res, ErrorCodes.TypeMismatch); +assert.commandFailedWithCode(res, [16554, ErrorCodes.TypeMismatch]); st.stop(); }()); |