-
Type:
Bug
-
Resolution: Done
-
Priority:
Critical - P2
-
Affects Version/s: bson-3.2.0, bson-3.2.2
-
Component/s: BSON
-
None
-
None
-
Major Change
-
None
-
None
-
None
-
None
-
None
-
None
We've noticed a regression while upgrading to bson 3.2.3 from bson 1.8: BSON::Document#merge yields to the provided block even when the key is not present in both hashes. This is incompatible with previous version of bson (at least 1.x) and most importantly Ruby's Hash#merge:
Ruby only yields for keys present in both hashes:
{a: 1}.merge(b: 1) { |k, old, new| old + new} # => {a: 1, b: 1}
While bson 3 yields to #merge even if keys are not present in both hashes. This results in the following:
a = BSON::Document.new(a: 1) a.merge(b: 1) { |k, old, new| old + new } # => undefined method `+' for nil:NilClass
I will submit a patch soon, that fixes the issue.