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

BSON fails to deserialize large Dates

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.6.3
    • Component/s: None
    • Labels:
    • Environment:
      Ubuntu 11.10, 32-bit system

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: