-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
BSON::ObjectId.as_json returns a {{
{"$oid"=>"...."}}}, So when querying, we should accept queries like:User.find({"$oid"=>"53adc74563616ef6e2290000"}) # and User.where({"_id" => {"$oid"=>"53adc74563616ef6e2290000"} })
This would solve a lot of serialization issues, where user._id.to_json is called to serialize the user, and afterwards some other process try to query using that id, which is a {{{"$oid"=>"...."}
}}.
That might be moped responsibility instead of Mongoid. Maybe, the main mongodb ruby driver should follow this pattern too.
WDYT durran @estolfo
[related https://github.com/plataformatec/devise/pull/2882]
[related https://github.com/mongoid/mongoid/issues/3702]
Besides this change, for Mongoid 4.1.x , to_key method, should not return a BSON::ObjectId, and it should return a string instead. As the to_key AM api is used mainly to serialize ids, which are suppose to be int or strings.