-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
Fully Compatible
Per jmikola , if a hash that contains $ref but not $id is deserialized , it produces a DBRef that has a nil $id:
irb(main):004:0> b={'$ref'=>'x'} => {"$ref"=>"x"} irb(main):005:0> Hash.from_bson(BSON::ByteBuffer.new(b.to_bson.to_s)) => #<Mongo::DBRef:0x000055f8a0fd8ec0 @collection="x", @id=nil, @database=nil> irb(main):006:0> Hash.from_bson(BSON::ByteBuffer.new(b.to_bson.to_s)).as_json => {"$ref"=>"x", "$id"=>nil} Note the $id field is also added where there wasn't one previously.