-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
The find_one_and_* methods automatically get the first element from the result and get the value for the key "value". When write_concern is {{
{w:0}}} only the empty list is returned, and this leads to the following error:
#<NoMethodError: undefined method `[]' for nil:NilClass>
This can be reproduced using the following code:
context 'when unacknowledged writes is used on find_one_and_update' do let(:selector) do { name: 'BANG' } end let(:collection_with_unacknowledged_write_concern) do authorized_collection.with(write: { w: 0 }) end let(:result) do collection_with_unacknowledged_write_concern.find_one_and_update(selector, { '$set' => { field: 'testing' }}, write_concern: { w: 0 }) end it 'does not raise an exception' do expect(result.inserted_count).to be(0) end end