-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 5.2.1, 6.2.1
-
Component/s: None
-
None
When using the `atomically` method to combine multiple atomic operations into a single mongo operation, if zero atomic operations are created by the block, then mongoid issues an incorrect update operation with an empty document `{}`.
This completely erases the underlying document.
Expected Behaviour: There should be no update, and no loss of data.
Example:
SomeModel.rb
class SomeModel include Mongoid::Document def perform_some_updates atomically do set(:foo, 'bar') if some_condition set(:baz: 'quux') if other_condition # etc end end
If both of the conditionals in the example evaluate to false, then models data is unexpectedly lost.