2020-08-13 19:13:40 -04:00
|
|
|
// @tags: [
|
|
|
|
|
// requires_non_retryable_writes,
|
2025-11-21 12:33:41 -05:00
|
|
|
// requires_getmore,
|
|
|
|
|
// # Time series collections do not support indexing array values in measurement fields.
|
|
|
|
|
// exclude_from_timeseries_crud_passthrough,
|
2020-08-13 19:13:40 -04:00
|
|
|
// ]
|
2017-11-28 10:10:44 -05:00
|
|
|
|
2011-07-31 08:44:33 -07:00
|
|
|
// Test query empty array SERVER-2258
|
|
|
|
|
|
|
|
|
|
let t = db.jstests_arrayfind4;
|
|
|
|
|
t.drop();
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.save({a: []});
|
2020-11-17 13:45:05 +00:00
|
|
|
t.createIndex({a: 1});
|
2011-07-31 08:44:33 -07:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(1, t.find({a: []}).hint({$natural: 1}).itcount());
|
|
|
|
|
assert.eq(1, t.find({a: []}).hint({a: 1}).itcount());
|
2011-07-31 08:44:33 -07:00
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.eq(
|
|
|
|
|
1,
|
|
|
|
|
t
|
|
|
|
|
.find({a: {$in: [[]]}})
|
|
|
|
|
.hint({$natural: 1})
|
|
|
|
|
.itcount(),
|
|
|
|
|
);
|
|
|
|
|
assert.eq(
|
|
|
|
|
1,
|
|
|
|
|
t
|
|
|
|
|
.find({a: {$in: [[]]}})
|
|
|
|
|
.hint({a: 1})
|
|
|
|
|
.itcount(),
|
|
|
|
|
);
|
2011-07-31 08:44:33 -07:00
|
|
|
|
2014-02-02 11:21:12 -05:00
|
|
|
t.remove({});
|
2016-03-09 12:17:50 -05:00
|
|
|
t.save({a: [[]]});
|
2011-07-31 08:44:33 -07:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(1, t.find({a: []}).hint({$natural: 1}).itcount());
|
|
|
|
|
assert.eq(1, t.find({a: []}).hint({a: 1}).itcount());
|
2011-07-31 08:44:33 -07:00
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
assert.eq(
|
|
|
|
|
1,
|
|
|
|
|
t
|
|
|
|
|
.find({a: {$in: [[]]}})
|
|
|
|
|
.hint({$natural: 1})
|
|
|
|
|
.itcount(),
|
|
|
|
|
);
|
|
|
|
|
assert.eq(
|
|
|
|
|
1,
|
|
|
|
|
t
|
|
|
|
|
.find({a: {$in: [[]]}})
|
|
|
|
|
.hint({a: 1})
|
|
|
|
|
.itcount(),
|
|
|
|
|
);
|