diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-10-02 17:24:03 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-10-05 16:47:26 -0400 |
commit | cb9f7cdcb7eb6ad9077ac8af3a4c0d7275c7e34f (patch) | |
tree | 24fea4c596a4652a457bc496d34a5590b7882190 /jstests/aggregation | |
parent | e02285559b5f15be6afbf876f169874bd9008b0b (diff) | |
download | mongo-cb9f7cdcb7eb6ad9077ac8af3a4c0d7275c7e34f.tar.gz |
SERVER-30731 Add expr support in MatchExpression outside of aggregation
Diffstat (limited to 'jstests/aggregation')
-rw-r--r-- | jstests/aggregation/sources/graphLookup/error.js | 4 | ||||
-rw-r--r-- | jstests/aggregation/sources/graphLookup/filter.js | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/jstests/aggregation/sources/graphLookup/error.js b/jstests/aggregation/sources/graphLookup/error.js index 143ea5bc31f..20dad85b842 100644 --- a/jstests/aggregation/sources/graphLookup/error.js +++ b/jstests/aggregation/sources/graphLookup/error.js @@ -302,10 +302,10 @@ load("jstests/aggregation/extras/utils.js"); // For "assertErrorCode". connectToField: "a", connectFromField: "b", as: "output", - restrictSearchWithMatch: {$expr: {$eq: ["$x", 5]}} + restrictSearchWithMatch: {$expr: {$eq: ["$x", "$$unbound"]}} } }; - assertErrorCode(local, pipeline, 40186, "cannot use $expr inside $graphLookup"); + assertErrorCode(local, pipeline, 17276, "cannot use $expr with unbound variable"); // $graphLookup can only consume at most 100MB of memory. var foreign = db.foreign; diff --git a/jstests/aggregation/sources/graphLookup/filter.js b/jstests/aggregation/sources/graphLookup/filter.js index 15ff6d4a4ae..b6eaff41b25 100644 --- a/jstests/aggregation/sources/graphLookup/filter.js +++ b/jstests/aggregation/sources/graphLookup/filter.js @@ -75,4 +75,20 @@ .toArray()[0]; assert.eq(res.results.length, 1); + + // $expr is allowed inside the 'restrictSearchWithMatch' match expression. + // TODO SERVER-31029: This should not throw once support is added for top-level $expr within $or + // and $and. + assert.throws(function() { + local.aggregate({ + $graphLookup: { + from: "foreign", + startWith: "$starting", + connectFromField: "to", + connectToField: "from", + as: "results", + restrictSearchWithMatch: {$expr: {$eq: ["$shouldBeIncluded", true]}} + } + }); + }); })(); |