-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: BSON
-
None
Driver's DBRef class overrides Hash.from_bson to specially handle hashes with $ref keys and produce a DBRef in this case.
Unfortunately, DBRef is not a subclass of Hash, which can cause problems because now the type of return value of from_hash depends on the data being deserialized.
This probably should be repaired as part of common DBRef work.
Note that the override happens in the driver, not in bson-ruby.
irb(main):007:0> e={'$ref'=>'x','$id'=>123,'x'=>42} => {"$ref"=>"x", "$id"=>123, "x"=>42} irb(main):011:0> Hash.from_bson(BSON::ByteBuffer.new(e.to_bson.to_s)).is_a?(Hash) => false