-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
Fully Compatible
In bson-4.8.0 the #from_bson method was changed to take **options. In older Ruby driver releases there is a DBRef class which has a #from_bson implementation that does not accept the **options, resulting in failures in Mongoid that look like the following:
W, [2020-02-28T16:19:15.067868 #10134] WARN -- : MONGODB | Failed to handshake with localhost:14420: ArgumentError: wrong number of arguments (given 2, expected 1): /home/w/.rbenv/versions/jruby-9.2.7.0/lib/ruby/gems/shared/gems/mongo-2.11.3/lib/mongo/dbref.rb:115:in `from_bson' /home/w/.rbenv/versions/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bson-4.8.0-java/lib/bson/hash.rb:115:in `from_bson' /home/w/.rbenv/versions/jruby-9.2.7.0/lib/ruby/gems/shared/gems/mongo-2.11.3/lib/mongo/dbref.rb:104:in `from_bson' /home/w/.rbenv/versions/jruby-9.2.7.0/lib/ruby/gems/shared/gems/mongo-2.11.3/lib/mongo/protocol/serializers.rb:354:in `deserialize' /home/w/.rbenv/versions/jruby-9.2.7.0/lib/ruby/gems/shared/gems/mongo-2.11.3/lib/mongo/protocol/message.rb:306:in `block in deserialize_array' /home/w/.rbenv/versions/jruby-9.2.7.0/lib/ruby/gems/shared/gems/mongo-2.11.3/lib/mongo/protocol/message.rb:306:in `deserialize_array'
The call to #from_bson needs to check for options being empty and omit the **options in that case.