mongo/jstests/core/query/array/arrayfind5.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

27 lines
621 B
JavaScript

// Test indexed elemmatch of missing field.
// @tags: [
// requires_getmore
// ]
let t = db.jstests_arrayfind5;
t.drop();
function check(nullElemMatch) {
assert.eq(1, t.find({"a.b": 1}).itcount());
assert.eq(1, t.find({a: {$elemMatch: {b: 1}}}).itcount());
assert.eq(nullElemMatch ? 1 : 0, t.find({"a.b": null}).itcount());
assert.eq(nullElemMatch ? 1 : 0, t.find({a: {$elemMatch: {b: null}}}).itcount()); // see SERVER-3377
}
t.save({a: [{}, {b: 1}]});
check(true);
t.createIndex({"a.b": 1});
check(true);
t.drop();
t.save({a: [5, {b: 1}]});
check(false);
t.createIndex({"a.b": 1});
check(false);