-
Type: Task
-
Resolution: Fixed
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
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?
- is related to
-
MONGOID-4533 Deprecate Symbol field type
- Closed
-
RUBY-1321 Update documentation to reflect Symbol deprecation
- Closed