Files
mongo/jstests/core/query/update/update_arraymatch7.js
Enrico Golfieri 92fc7e9ad4 SERVER-115731 Deploy 3 mongos for the remaining sharding_jscore_passthrough_* suites (#46877)
GitOrigin-RevId: 801504c951222e7260a2023cc0bf684b9e99e961
2026-02-04 17:37:09 +00:00

33 lines
1.1 KiB
JavaScript

// @tags: [
// requires_non_retryable_writes,
// # Time series collections do not support indexing array values in measurement fields.
// exclude_from_timeseries_crud_passthrough,
// ]
// Check that the positional operator works properly when an index only match is used for the update
// query spec. SERVER-5067
// TODO (SERVER-117130): Remove the mongos pinning once the related issue is resolved.
// When a database is dropped, a stale router will report "database not found" error for
// deletes (instead of "ok") when pauseMigrationsDuringMultiUpdates is enabled.
if (TestData.pauseMigrationsDuringMultiUpdates) {
TestData.pinToSingleMongos = true;
}
const t = db[jsTestName()];
t.drop();
function testPositionalInc() {
assert.commandWorked(t.remove({}));
assert.commandWorked(t.save({a: [{b: "match", count: 0}]}));
assert.commandWorked(t.update({"a.b": "match"}, {$inc: {"a.$.count": 1}}));
// Check that the positional $inc succeeded.
assert(t.findOne({"a.count": 1}));
}
testPositionalInc();
// Now check with a non multikey index.
assert.commandWorked(t.createIndex({"a.b": 1}));
testPositionalInc();