Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3702

Serialization of BSON:ObjectId

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0
    • Affects Version/s: None
    • Component/s: None

      Hello,

      at the moment,

      o = SomeClass.new
      id = JSON.dump o.id
      => "

      {\"$oid\":\"53aa928b6176721976000000\"}

      "
      id = JSON.load id
      =>

      {"$oid"=>"53aa928b6176721976000000"}
      SomeClass.find(:id => id) # This fails

      This is the process used by sidekiq to serialize parameters for its tasks btw.

      Is there a way to query for a record by passing the {{{"$oid"=>"53aa928b6176721976000000"}

      }} hash directly?

      That would give the symmetric behavior expected of when pushing an id to sidekiq, you retrieve an id in the worker (instead of a hash).

            Assignee:
            Unassigned Unassigned
            Reporter:
            muichkine Olivier Milla
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: