summaryrefslogtreecommitdiff
path: root/jstests/aggregation/bugs/server6570.js
blob: b12a83967bab09d359eeb7c99a334340ba0b0b63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// ensure $add asserts on string
load('jstests/aggregation/extras/utils.js');
load("jstests/libs/sbe_assert_error_override.js");  // Override error-code-checking APIs.

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"]}}}, [16554, ErrorCodes.TypeMismatch]);
assertErrorCode(c,
                {$project: {number_fields: {$add: ["a", "$x", "b", "$x"]}}},
                [16554, ErrorCodes.TypeMismatch]);
assertErrorCode(
    c, {$project: {all_strings: {$add: ["c", "$y", "d", "$y"]}}}, [16554, ErrorCodes.TypeMismatch]);
assertErrorCode(
    c, {$project: {potpourri_1: {$add: [5, "$y", "e", "$x"]}}}, [16554, ErrorCodes.TypeMismatch]);
assertErrorCode(
    c, {$project: {potpourri_2: {$add: [6, "$x", "f", "$y"]}}}, [16554, ErrorCodes.TypeMismatch]);
assertErrorCode(
    c, {$project: {potpourri_3: {$add: ["g", "$y", 7, "$x"]}}}, [16554, ErrorCodes.TypeMismatch]);
assertErrorCode(
    c, {$project: {potpourri_4: {$add: ["h", "$x", 8, "$y"]}}}, [16554, ErrorCodes.TypeMismatch]);