BSON::Document#to_h does not convert nested hashes

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Won't Do
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Ruby Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      BSON::Document#to_h does not convert nested hashes. I think this behavior is non-optimal/surprising:

       

      doc = BSON::Document.new({"foo" => {"bar" => 100}})
      
      doc.class #=> BSON::Document -- OK
      
      doc['foo'].class #=> BSON::Document -- OK
      
      hash = doc.to_h
      
      hash.class #=> Hash -- OK
      
      hash['foo'].class #=> BSON::Document -- YIKES, UNEXPECTED!!

      I think this is probably ok to fix without adding a feature flag, since BSON::Document is already "duck-typed" to have the same methods as Hash, I can't imagine fixing it will actually break any apps.

       

            Assignee:
            Unassigned
            Reporter:
            Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: