summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorJacob Evans <jacob.evans@10gen.com>2020-06-08 12:33:42 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-10 02:22:04 +0000
commited16dca5ef0d474f487af5ca40729fec8dab7102 (patch)
treeb99d28096d0e2927b4eb5bfe6b169462fdcb0044 /jstests/core
parentad170b9f34c828ec25404f600e95416639e1fecd (diff)
downloadmongo-ed16dca5ef0d474f487af5ca40729fec8dab7102.tar.gz
SERVER-46738 Ensure let parameters work for sharded find
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/command_let_variables.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/jstests/core/command_let_variables.js b/jstests/core/command_let_variables.js
index 5f75fb438bd..6baf9a1e99a 100644
--- a/jstests/core/command_let_variables.js
+++ b/jstests/core/command_let_variables.js
@@ -223,4 +223,23 @@ assert.eq(db.runCommand({
"let": {variable: "OUTER"}
}).cursor.firstBatch.length,
2);
+
+// Test that the find command works correctly with a let parameter argument.
+let result = assert
+ .commandWorked(db.runCommand({
+ find: coll.getName(),
+ let : {target_species: "Song Thrush (Turdus philomelos)"},
+ filter: {$expr: {$eq: ["$Species", "$$target_species"]}},
+ projection: {_id: 0}
+ }))
+ .cursor.firstBatch;
+expectedResults = {
+ Species: "Song Thrush (Turdus philomelos)",
+ population_trends: [
+ {term: {start: 1970, end: 2014}, pct_change: -53, annual: -1.7, trend: "weak decline"},
+ {term: {start: 2009, end: 2014}, pct_change: -4, annual: -0.88, trend: "no change"}
+ ]
+};
+assert.eq(result.length, 1);
+assert.eq(expectedResults, result[0]);
}());