diff options
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/where_multiple_plans.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/core/where_multiple_plans.js b/jstests/core/where_multiple_plans.js new file mode 100644 index 00000000000..86f2e050747 --- /dev/null +++ b/jstests/core/where_multiple_plans.js @@ -0,0 +1,33 @@ +/** + * Tests that a $where predicate works as expected when there are multiple candidate plans. + * + * @tags: [ + * requires_fcv_60, + * requires_scripting, + * ] + */ +(function() { +"use strict"; + +const coll = db.where_multiple_plans; +coll.drop(); + +assert.commandWorked(coll.createIndex({a: 1})); +assert.commandWorked(coll.createIndex({b: 1})); + +assert.commandWorked(coll.insert({_id: 0, a: 1, b: 3, c: 4})); +assert.commandWorked(coll.insert({_id: 1, a: 2, b: 1, c: 4})); +assert.commandWorked(coll.insert({_id: 2, a: 2, b: 3, c: 1})); +assert.commandWorked(coll.insert({_id: 3, a: 2, b: 3, c: 4})); +assert.commandWorked(coll.insert({_id: 4, a: 2, b: 3, c: 4})); + +assert.eq(2, + coll.find({ + a: {$eq: 2}, + b: {$eq: 3}, + $where: function() { + return this.c == 4; + } + }) + .itcount()); +}()); |