'as_document' does not contain symbolized keys for in-memory documents

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 6.0.0
    • Affects Version/s: 5.1.3
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When pulling objects from the database, the 'as_document' returned hash has both symbols and strings as keys, however for in-memory documents the hash contains only string keys. For example

      class Search
      include Mongoid::Document
      field :name, type: String
      end

      Search.new(name: "test").as_document["name"] => "test"
      Search.new(name: "test").as_document[:name] => nil
      Search.create(name: "test").as_document["name"] => "test"
      Search.create(name: "test").as_document[:name] => nil
      Search.first.as_document[:name] => "test"
      Search.first.as_document["name"] => "test"

              Assignee:
              Emily Stolfo (Inactive)
              Reporter:
              George L
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: