diff options
author | Will Buerger <will.buerger@mongodb.com> | 2022-12-21 20:20:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-12-21 21:16:16 +0000 |
commit | ebbb36a531d6a137d817c4f833050da3964411dd (patch) | |
tree | 416d77e6cc9010da4058c23f5894f0adc517d24c /jstests/cqf/basic_agg_expr.js | |
parent | 5977e706431fd5705b59115ec0e0d2d7a2203246 (diff) | |
download | mongo-ebbb36a531d6a137d817c4f833050da3964411dd.tar.gz |
SERVER-71500: fix reverseComparisonOp to reverse instead of negate
Diffstat (limited to 'jstests/cqf/basic_agg_expr.js')
-rw-r--r-- | jstests/cqf/basic_agg_expr.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/jstests/cqf/basic_agg_expr.js b/jstests/cqf/basic_agg_expr.js index 4c66a8799e0..0578717f5fd 100644 --- a/jstests/cqf/basic_agg_expr.js +++ b/jstests/cqf/basic_agg_expr.js @@ -81,4 +81,59 @@ const t = db.cqf_agg_expr; assertArrayEq({actual: res, expected: [{_id: 1, a: [{b: 1}]}, {_id: 3, a: {b: [1]}}]}); } } +{ + t.drop(); + assert.commandWorked(t.insert({_id: 0, a: 1})); + assert.commandWorked(t.insert({_id: 1, a: 2})); + assert.commandWorked(t.insert({_id: 2, a: 3})); + + { + const res = t.aggregate([{$match: {$expr: {$lt: [2, "$a"]}}}]).toArray(); + + assert.eq(1, res.length); + assert.eq(3, res[0].a); + } + { + const res = t.aggregate([{$match: {$expr: {$gt: ["$a", 2]}}}]).toArray(); + + assert.eq(1, res.length); + assert.eq(3, res[0].a); + } + { + const res = t.aggregate([{$match: {$expr: {$lte: [2, "$a"]}}}]).toArray(); + + assert.eq(2, res.length); + assertArrayEq({actual: res, expected: [{_id: 1, a: 2}, {_id: 2, a: 3}]}); + } + { + const res = t.aggregate([{$match: {$expr: {$gte: ["$a", 2]}}}]).toArray(); + + assert.eq(2, res.length); + assertArrayEq({actual: res, expected: [{_id: 1, a: 2}, {_id: 2, a: 3}]}); + } + { + const res = t.aggregate([{$match: {$expr: {$gt: [3, "$a"]}}}]).toArray(); + + assert.eq(2, res.length); + assertArrayEq({actual: res, expected: [{_id: 0, a: 1}, {_id: 1, a: 2}]}); + } + { + const res = t.aggregate([{$match: {$expr: {$lt: ["$a", 3]}}}]).toArray(); + + assert.eq(2, res.length); + assertArrayEq({actual: res, expected: [{_id: 0, a: 1}, {_id: 1, a: 2}]}); + } + { + const res = t.aggregate([{$match: {$expr: {$gte: [3, "$a"]}}}]).toArray(); + + assert.eq(3, res.length); + assertArrayEq({actual: res, expected: [{_id: 0, a: 1}, {_id: 1, a: 2}, {_id: 2, a: 3}]}); + } + { + const res = t.aggregate([{$match: {$expr: {$lte: ["$a", 3]}}}]).toArray(); + + assert.eq(3, res.length); + assertArrayEq({actual: res, expected: [{_id: 0, a: 1}, {_id: 1, a: 2}, {_id: 2, a: 3}]}); + } +} }()); |