diff options
author | James Wahlin <james@mongodb.com> | 2020-05-04 09:41:41 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-04 18:16:58 +0000 |
commit | 94e95fe7501e3c3b09f1e63592ba9557a3dc66c9 (patch) | |
tree | 11b4a45d48174c84c1e865055c809270eecd790e | |
parent | 1abf05a44fbb0d072ebdb3fb133e35e0c17c57e3 (diff) | |
download | mongo-94e95fe7501e3c3b09f1e63592ba9557a3dc66c9.tar.gz |
SERVER-47893 Add test confirming that variables defined above a $graphLookup are available for use
(cherry picked from commit b60db3513af2905e0bf4aa9865364d07a46ac4b8)
(cherry picked from commit 54c4f1a963c220eacf7ed7cb6a052affcb954725)
-rw-r--r-- | jstests/aggregation/sources/graphLookup/filter.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/aggregation/sources/graphLookup/filter.js b/jstests/aggregation/sources/graphLookup/filter.js index 4b46c843d9a..da828cb66c7 100644 --- a/jstests/aggregation/sources/graphLookup/filter.js +++ b/jstests/aggregation/sources/graphLookup/filter.js @@ -91,4 +91,28 @@ res = local .toArray()[0]; assert.eq(res.results.length, 1); + +// $expr within `restrictSearchWithMatch` has access to variables declared at a higher level. +res = local + .aggregate([{ + $lookup: { + from: "local", + let : {foo: true}, + pipeline: [{ + $graphLookup: { + from: "foreign", + startWith: "$starting", + connectFromField: "to", + connectToField: "from", + as: "results", + restrictSearchWithMatch: + {$expr: {$eq: ["$shouldBeIncluded", "$$foo"]}} + } + }], + as: "array" + } + }]) + .toArray()[0]; + +assert.eq(res.array[0].results.length, 1); })(); |