Skip to content

Commit e7802e5

Browse files
authored
MONGOID-4823 Values for BSON::Binary fields are not converted to Binary (#5317)
* MONGOID-4823 add (de)mongoize for Binary * MONGOID-4823 add tests for ObjectId * MONGOID-4823 add release note * MONGOID-4823 fix comment * MONGOID-4823 answer comments * MONGOID-4823 use ::BSON * Revert "MONGOID-4823 use ::BSON" This reverts commit 5c893e93562b9d3855adaa8411a4d35e0455fd31. * MONGOID-4823 revert back to without ::BSON * MONGOID-4823 fix document test
1 parent 52c0add commit e7802e5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

source/release-notes/mongoid-8.0.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,28 @@ For example:
447447

448448
As you can see from this example, after pushing ``user2`` to the users array,
449449
Mongoid 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...>

0 commit comments

Comments
 (0)