Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2146

Support older driver versions for BSON deserialization

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-4.8.1, bson-4.8.2
    • 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.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: