-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Attributes
There have been several inquiries/requests to improve symbol handling in Mongoid. In Ruby, Symbol is a valid and commonly used type, and currently there isn't a great way to work with symbols in Ruby code while persisting them in MongoDB in a way that is interoperable with other drivers and does not use deprecated functionality like the bson symbol type.
This ticket proposes adding a StringifiedSymbol field type to Mongoid, which will behave as follows:
- The value is stored in MongoDB as a string.
- The value is exposed to Ruby applications as a symbol.
Because this will be a new field, we can also add some migration assistance logic as follows:
- If the field reads a bson symbol value out of MongoDB, it is exposed to the applications as a symbol.
- Writes always use the string type.
In this way applications can replace their existing Symbol types with StringifiedSymbol and have the data be gradually converted upon writes. Similarly an application can use StringifiedSymbol to work with data that is also read/written by other languages (where it would be presented as strings).
- is duplicated by
-
MONGOID-4900 Add Symbol Type Conversion to String
- Closed
-
MONGOID-4989 Do not deprecate Symbol type
- Closed
- related to
-
RUBY-2021 Ruby driver still uses deprecated symbol type
- Closed
-
RUBY-2297 Broken formatting on BSON documentation
- Closed
-
MONGOID-4839 Add test coverage for symbol round-tripping in Hash field values
- Closed
- links to