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

Serializing a Hash throws undefined method

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: BSON
    • Environment:
      OSX
      ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin13.0.2]
      BSON version 2.2.2
    • Fully Compatible

      Serializing a hash with an Object Id throws an undefined method error.

      1.9.3-p374 :001 > {:custom_fields=>{BSON::ObjectId.from_string('53593be85261753a38000000')=>"ABC", BSON::ObjectId.from_string('53593be85261753a38010000')=>["123", "234"]}}.to_bson
      NoMethodError: undefined method `to_bson_key' for BSON::ObjectId('53593be85261753a38000000'):BSON::ObjectId
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:45:in `block (2 levels) in to_bson'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `each'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `block in to_bson'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/encodable.rb:57:in `encode_with_placeholder_and_null'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:42:in `to_bson'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:46:in `block (2 levels) in to_bson'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `each'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:43:in `block in to_bson'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/encodable.rb:57:in `encode_with_placeholder_and_null'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/bson-2.2.2/lib/bson/hash.rb:42:in `to_bson'
      from (irb):1
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in `start'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in `start'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in `console'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
      from /Users/me/.rvm/gems/ruby-1.9.3-p374/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
      from bin/rails:4:in `require'

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            ismell Raul E Rangel
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: