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

BSON fails to deserialize large Dates

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.3
    • Affects Version/s: 1.6.2
    • Component/s: None
    • Environment:
      Ubuntu 11.10, 32-bit system

      The ruby BSON implementation is broken for large Dates.

      The following snippet reproduces it in IRB;

      ruby-1.9.2-p290 :001 > require 'bson'
      ruby-1.9.2-p290 :002 > require 'date'
      ruby-1.9.2-p290 :003 > BSON.deserialize BSON.serialize(t: DateTime.parse('2099-01-01T00:00:00Z').to_time)
      =>

      {"t"=>1962-11-25 17:31:44 UTC}

      Note a year of 2099 was the parameter for serialization, while 1962 was the result after deserialization. Since both Mongo and rubys Time-class can handle 64-bit time-instances, the BSON-serialization-step should really handle it too.

      As a side-note, when originally discovering this in my Mongo-app, the database actually had a correct 2099-date inserted through the ruby-driver, so I would expect the problem to be in de-serialization rather than serialization.

      I have both bson, and bson_ext gems installed, unsure of which is used.

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            rawler Ulrik Mikaelsson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: