-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When deserializing a hash which contains a $ref field, thus producing a DBRef, if there are additional fields other than $ref/$id/$db those are dropped from the DBRef object and subsequently aren't serialized back.
The extended json spec says additional fields are permitted.
irb(main):007:0> e={'$ref'=>'x','$id'=>123,'x'=>42}
=> {"$ref"=>"x", "$id"=>123, "x"=>42}
irb(main):008:0> Hash.from_bson(BSON::ByteBuffer.new(e.to_bson.to_s))
=> #<Mongo::DBRef:0x000055f8a0ff04a8 @collection="x", @id=123, @database=nil>
irb(main):009:0> Hash.from_bson(BSON::ByteBuffer.new(e.to_bson.to_s)).to_json
=> "{\"$ref\":\"x\",\"$id\":123}"
irb(main):010:0> Hash.from_bson(BSON::ByteBuffer.new(e.to_bson.to_s)).as_json
=> {"$ref"=>"x", "$id"=>123}