Regression Bug: Field type Hash does not typecast to Hash correctly

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 9.0.6
    • Component/s: None
    • None
    • None
    • Ruby Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Given the following setup:

      def MyModel
        include Mongoid::Document
        field :my_hash, type: Hash
      end
      
      doc = MyModel.new(my_hash: { foo: { bar: 1 } }
      
      doc = MyModel.all.first

      On Mongoid 7.x:

      doc.my_hash.class #=> Hash -- CORRECT
      doc.my_hash['foo'].class #=> Hash -- CORRECT 

      On Mongoid 9.x:

      doc.my_hash.class #=> Mongoid::Document -- BAD
      doc.my_hash['foo'].class #=> Mongoid::Document -- BAD

       

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

              Created:
              Updated: