stripe-archive / mosql

MongoDB → PostgreSQL streaming replication
MIT License
1.63k stars 225 forks source link

Dropping milliseconds while reading #55

Closed AndreaCrotti closed 10 years ago

AndreaCrotti commented 10 years ago

It looks like there is a small issue when importing documents with datetimes.

Basically what happens is that the milliseconds get dropped, these are the values in Mongo and Postgres:

datetime.datetime(2014, 8, 21, 17, 27, 9, 424000)
datetime.datetime(2014, 8, 21, 18, 27, 9)

I suspect the problem is in here, is it possible?

      case v
      when BSON::Binary, BSON::ObjectId, Symbol
        v = v.to_s
      when BSON::DBRef
        v = v.object_id.to_s
      when Hash
        v = JSON.dump(v)
      when Array
        if col[:array_type]
          v = Sequel.pg_array(v, col[:array_type])
        else
          v = JSON.dump(v)
        end
      end

Thanks

nelhage commented 10 years ago

Thanks! Should be resolved