Skip to content

Commit c556b9e

Browse files
authored
MONGOID-5234 Add Feature Flag: Remove BSON::ObjectId#as_json override (#5141)
* Revert "MONGOID-???? - Remove BSON::ObjectId#as_json as we will defer to the bson-ruby gem implementation. (#5057)" This reverts commit e8aae8896403794285083205456489ff525dc298. * MONGOID-5234 add feature flag for as_json * MONGOID-5234 add docs for new feature flag * MONGOID-5234 remove irrelevant tests and add docstring * MONGOID-5234 add default to configuration docs * MONGOID-5234 use dots instead of :: * MONGOID-5234 put test back * MONGOID-5234 update documentation and flip the flag * MONGOID-5234 fix up as_json comment * MONGOID-5234 update release notes * MONGOID-5234 change method signature
1 parent 4191b0d commit c556b9e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

source/reference/configuration.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ for details on driver options.
372372
# further information. (default: true)
373373
use_activesupport_time_zone: true
374374

375+
# In Mongoid 7.3.3 and earlier, the BSON::ObjectId#as_json method would
376+
# default to returning { "$oid" => id.to_s }. Turning on this flag will
377+
# defer the as_json call to bson-ruby's implementation of
378+
# BSON::ObjectId#as_json. In bson-ruby 5.x.x as_json will return
379+
# the id as a string. In bson-ruby 4.x.x as_json will return
380+
# { "$oid" => id.to_s }. (default: false)
381+
use_bson_ruby_as_json: false
382+
375383
# Return stored times as UTC. See the time zone section below for
376384
# further information. Most applications should not use this option.
377385
# (default: false)

source/release-notes/mongoid-7.4.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ Mongoid 7.4 and later will inherit the new implementation provided by
118118
``bson-ruby`` while Mongoid 7.3 and earlier will continue with the
119119
implementation returning a hash of ``{"$oid" => "..."}``.
120120

121+
.. note::
122+
123+
In order to get this functionality, the ``Mongoid.use_bson_ruby_as_json``
124+
feature flag must be turned on.
121125

122126
Scoped Associations
123127
-------------------

0 commit comments

Comments
 (0)