Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1320

Cleanup of Symbol confusion

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I stumbled upon ruby mongodb code, that is controversial in my eyes.

      Since Symbols are deprecated in bson, the ruby bson gem changed the bson representation of ruby symbols here. From then on, they where represented the same way like strings.

      However, in RUBY-1075 that change is overwritten. Symbols are now again represented as the (deprecated) symbols (with \x0E).

      This results in all apps that use the ruby-driver like

      client[:some_collection].insert_one({color: :blue})
      

      or all apps that use mongoid with symbol fields like

      class SomeModel
        include Mongoid::Document
        field :color, type: Symbol
      end
      

      to produce data that is incompatible to several mongodb tools.

      Examples are mongoexport / bsondump. They at least give an error message like the following:

      unable to dump document 1: error converting BSON to extended JSON: conversion of BSON value 'blue' of type 'bson.Symbol' not supported

      .
      But there are also other tools like mongodrdl (from bi connector) which just ignore those fields [MMSSUPPORT-20746].

      So, what is the correct way of handling the ruby symbols? In my eyes, that at least includes

      • offering a simple and well documented way of convertig Symbols in the db to strings.
      • a deprecation warning for symbols in the ruby driver an / or mongoid

      What is your opinion about that?

            Assignee:
            sam.rossi@mongodb.com Samuel Rossi (Inactive)
            Reporter:
            roman.lehnert@givve.com Roman Lehnert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: