Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3124

Notify that Hash keys are automatically converted to String

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.5
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I had a Mongoid document with a field of Hash data type and assigned a value to a Hash key for which I used a :symbol for. When I tried to get that same value using hash[:key], I couldn't get it.

      Found out later that Mongoid automatically converts any symbols you use in hash keys into strings after testing in the console. I guess this has something to do with MongoDB not recognizing symbols and using only strings as keys.

      Anyway, it would be great if we could return a notification every time a user tries to access a hash value using a :symbol key along the lines of, "Mongoid automatically converts all symbols used as hash keys into strings. Try the string version instead."

      Would do this myself but not sure where to start in the Mongoid codebase for this. Would be great though if someone could guide me on this.

            Assignee:
            Unassigned Unassigned
            Reporter:
            gjaldon gjaldon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: