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

BSON_RUBY returns the wrong object from BSON.serialize

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ruby 1.9.1

      Without installing the bson_ext class, the return value of a call to BSON.serialize is an object of class BSON::BSON_RUBY:

      (irb) > BSON.serialize(:foo => 'bar')
      => #<BSON::BSON_RUBY:0x00000100abed78 @buf=#<BSON::ByteBuffer:0x00000100abed40 @buf=[18, 0, 0, 0, 2, 102, 111, 111, 0, 4, 0, 0, 0, 98, 97, 114, 0, 0], @cursor=4, @order=:little_endian, @int_pack_order="V", @double_pack_order="E">

      After installing the bson_ext class, the return value of the same call is the BSON::ByteBuffer:

      (irb) > BSON.serialize(:foo => 'bar')
      => #<BSON::ByteBuffer:0x0000010097c870 @buf="\x12\x00\x00\x00\x02foo\x00\x04\x00\x00\x00bar\x00\x00", @cursor=18, @order=:little_endian, @int_pack_order="V", @double_pack_order="E">

      I'm assuming that the bson_ext behavior is correct, because it matches the old behavior, and that the native Ruby driver is erroneously returning itself instead of the byte buffer it should be returning. Either way, they need to be consistent.

      I'm classing this as 'Major' because inconsistent serialization behavior makes it impossible for drivers to work without either requiring a bson_ext dependency or forcing it to be ignored. (E.g., I discovered the bug when attempting to update my Candy library to the 0.20.1 gems and my unit tests broke without bson_ext.)

            Assignee:
            kbanker Kyle Banker
            Reporter:
            sfeley Stephen Eley
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: