diff --git a/lib/mongoid/touchable.rb b/lib/mongoid/touchable.rb index 238658b987..01480d3189 100644 --- a/lib/mongoid/touchable.rb +++ b/lib/mongoid/touchable.rb @@ -39,12 +39,13 @@ def touch(field = nil) # seems to not always/ever be set here. See MONGOID-5014. _parent.touch - if field + if field.present? # If we are told to also touch a field, perform a separate write # for that field. See MONGOID-5136. # In theory we should combine the writes, which would require # passing the fields to be updated to the parents - MONGOID-5142. sets = set_field_atomic_updates(field) + puts sets.inspect selector = atomic_selector _root.collection.find(selector).update_one(positionally(selector, sets), session: _session) end