(function() { const t = db.find_and_modify; t.drop(); assert.commandWorked(t.insert({x: 1, y: 1, z: 1})); let result = t.findAndModify({ query: {x: 1}, 'new': false, update: {$set: {randomField: true}}, fields: {x: 1, y: 1} }); assert.eq(result.z, undefined); })();
This test will succeed when run in the 'core' suite. When run in retryable_writes_jscore_passthrough which retries each write at least once, it will fail. This is because this code only fetches the preimage/postimage of the document from the oplog, but does not re-apply the 'fields' projection. This means that the entire pre-image/post-image will always be returned.
- duplicates
-
SERVER-31242 findAndModify no-op retry should respect the fields option
- Open