Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor - P4 Minor - P4
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Backward Breaking:
      Rarely
    • # Replies:
      3
    • Last comment by Customer:
      true

      Description

      I happened to be perusing the BSON spec (http://bsonspec.org) and saw this:

      element ::= [ ... ]

      "\x0E" e_name string Symbol

      The mouseover tip says: "SYMBOL: Similar to a string but for languages with a distinct symbol type."

      The Ruby driver does not implement the Symbol type in any way distinct from String. If you save a document {:foo => "bar"} to Mongo and then query it again, you'll get back

      {"foo" => "bar"}

      .

      Given how fundamental symbols are as hash keys in idiomatic Ruby, it would be a very positive step forward for code convenience and a more transparent persistence layer if symbols could be saved to MongoDB as symbols.

      This change should not have much negative impact on existing applications, because code that's been translating symbols to strings this entire time will continue to do so. Only code that's reliant on inconsistency (i.e., that puts symbols in and explicitly relies on strings back out) would be fragile. Given that the symbol-to-string mapping is not documented in the API, I consider that to be relying on a bug.

        Activity

        Hide
        Michael Dirolf
        added a comment -

        symbol is already supported as best in can be - any time it is used in a value

        Show
        Michael Dirolf
        added a comment - symbol is already supported as best in can be - any time it is used in a value
        Hide
        Michael Dirolf
        added a comment -

        maybe we could do better doc'ing this though, as I've had to answer this question a ton of times. i'll leave that up to kyle

        Show
        Michael Dirolf
        added a comment - maybe we could do better doc'ing this though, as I've had to answer this question a ton of times. i'll leave that up to kyle
        Show
        Kyle Banker
        added a comment - Added to the FAQs: http://www.mongodb.org/display/DOCS/Frequently+Asked+Questions+-+Ruby#FrequentlyAskedQuestions-Ruby-IseethatBSONsupportsasymboltype.DoesthismeanthatIcanstoreRubysymbolsinMongoDB%3F

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since reply:
              4 years, 3 weeks, 3 days ago
              Date of 1st Reply: