File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -447,3 +447,28 @@ For example:
447447
448448As you can see from this example, after pushing ``user2`` to the users array,
449449Mongoid 8 correctly updates the number of elements without requiring a reload.
450+
451+
452+ Repaired Storing Strings in BSON::Binary fields
453+ -----------------------------------------------
454+
455+ In Mongoid 8, storing a String in a field of type ``BSON::Binary`` will be
456+ stored in and returned from the database as a ``BSON::Binary``. Prior to Mongoid 8
457+ it was stored and returned as a String.
458+
459+ .. code::
460+
461+ class Registry
462+ include Mongoid::Document
463+ field :data, type: BSON::Binary
464+ end
465+
466+ registry = Registry.create!(data: "data!")
467+ p registry.data
468+ # => Mongoid 7: "data!"
469+ # => Mongoid 8: <BSON::Binary:0x2580 type=generic data=0x6461746121...>
470+
471+ registry = Registry.find(registry.id)
472+ p registry.data
473+ # => Mongoid 7: "data!"
474+ # => Mongoid 8: <BSON::Binary:0x2600 type=generic data=0x6461746121...>
You can’t perform that action at this time.
0 commit comments