File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -259,15 +259,15 @@ def validate_isolation_level!(level)
259259 # consequences of duplicate index checking.
260260 option :allow_duplicate_index_declarations , default : false
261261
262- # When this flag is false , performing a serializable_hash(only: []) will
262+ # When this flag is true , performing a serializable_hash(only: []) will
263263 # result in all fields being included. This is the traditional (and default)
264264 # behavior in Mongoid 9 and earlier.
265265 #
266- # Setting this flag to true will change the behavior to suppress all fields
266+ # Setting this flag to false will change the behavior to suppress all fields
267267 # in the serialized hash. This will be the default in Mongoid 10.
268268 #
269269 # See https://jira.mongodb.org/browse/MONGOID-5892 for more details.
270- option :serializable_hash_with_legacy_only , default : false
270+ option :serializable_hash_with_legacy_only , default : true
271271
272272 # Returns the Config singleton, for use in the configure DSL.
273273 #
Original file line number Diff line number Diff line change @@ -79,11 +79,11 @@ def serializable_hash(options = nil)
7979 def field_names ( options )
8080 names = ( as_attributes . keys + attribute_names ) . uniq . sort
8181
82+ only = Array . wrap ( options [ :only ] ) . map ( &:to_s )
8283 except = Array . wrap ( options [ :except ] ) . map ( &:to_s )
8384 except |= [ self . class . discriminator_key ] unless Mongoid . include_type_for_serialization
8485
85- only = Array . wrap ( options [ :only ] ) . map ( &:to_s )
86- if !options [ :only ] . nil? && ( !Mongoid . serializable_hash_with_legacy_only || !only . empty? )
86+ if !options [ :only ] . nil? && ( Mongoid . serializable_hash_with_legacy_only || !only . empty? )
8787 names &= only
8888 elsif !except . empty?
8989 names -= except
Original file line number Diff line number Diff line change 302302 )
303303 end
304304
305- context "when serializable_hash_with_legacy_only == false " do # default for <= 9
306- config_override :serializable_hash_with_legacy_only , false
305+ context "when serializable_hash_with_legacy_only == true " do # default for <= 9
306+ config_override :serializable_hash_with_legacy_only , true
307307
308308 it "includes all fields when passed an empty array" do
309309 expect ( person . serializable_hash ( only : [ ] ) ) . to include attributes
310310 end
311311 end
312312
313- context "when serializable_hash_with_legacy_only == true " do # default for >= 10
314- config_override :serializable_hash_with_legacy_only , true
313+ context "when serializable_hash_with_legacy_only == false " do # default for >= 10
314+ config_override :serializable_hash_with_legacy_only , false
315315
316316 it "doesn't include any fields when passed an empty array" do
317317 expect ( person . serializable_hash ( only : [ ] ) ) . to be_empty
You can’t perform that action at this time.
0 commit comments