@@ -252,12 +252,12 @@ for details on driver options.
252
252
# Compressors to use. (default is to not use compression)
253
253
compressors: [zlib]
254
254
255
- # Configure Mongoid specific options. (optional)
255
+ # Configure Mongoid- specific options. (optional)
256
256
options:
257
- # Application name that is printed to the mongodb logs upon establishing
258
- # a connection in server versions >= 3.4. Note that the name cannot
259
- # exceed 128 bytes. It is also used as the database name if the
260
- # database name is not explicitly defined. (default: nil)
257
+ # Application name that is printed to the MongoDB logs upon establishing
258
+ # a connection in server versions 3.4 or greater . Note that the name
259
+ # cannot exceed 128 bytes in length . It is also used as the database name
260
+ # if the database name is not explicitly defined. (default: nil)
261
261
app_name: MyApplicationName
262
262
263
263
# Create indexes in background by default. (default: false)
@@ -268,30 +268,34 @@ for details on driver options.
268
268
# error. (default: true)
269
269
belongs_to_required_by_default: true
270
270
271
- # In Mongoid 7.3 and earlier, embedded matching performed time comparisons
272
- # with full (microsecond) precision. However, MongoDB server is only
273
- # capable of storing times with millisecond precision. Enabling this
274
- # option makes Mongoid truncate times to millisecond precision for
275
- # comparison purposes, to match the server behavior. (default: false)
276
- compare_time_by_ms: false
277
-
278
- # Set the global discriminator key. (default: "_type")
279
- discriminator_key: "_type"
280
-
281
- # Raise an exception when a field is redefined. (default: false)
282
- duplicate_fields_exception: false
283
-
284
- # In Mongoid 7.3.3 and earlier, the pluck and distinct operations did
285
- # not respect aliased fields for embedded documents. Turning on this
286
- # flag changes those functions to recognize those aliases.
287
- # (default: false)
288
- fix_embedded_alias_pluck_distinct: false
289
-
290
- # In Mongoid 7.3.3 and earlier, there was a bug when adding expressions
291
- # using the #and function. In certain situations, an $and clause would be
292
- # lost and replaced by one of the previous $and clauses. This would
293
- # happen when using the same operator on the same field multiple times.
294
- # For example:
271
+ # Maintain broken behavior of sum over empty result sets for backwards
272
+ # compatibility. When calculating a sum on a field with a null context,
273
+ # for example:
274
+ #
275
+ # Product.none.sum(:price)
276
+ #
277
+ # ... return field name (`:price') instead of 0.
278
+ #
279
+ # When calculating a sum via a database query with an empty result set,
280
+ # for example:
281
+ #
282
+ # Product.where(impossible_condition: true).sum(:price)
283
+ #
284
+ # ... return nil instead of 0.
285
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
286
+ broken_aggregables: true
287
+
288
+ # Ignore aliased fields in embedded documents when performing pluck and
289
+ # distinct operations, for backwards compatibility.
290
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
291
+ broken_alias_handling: true
292
+
293
+ # Maintain broken `and' method behavior that existed in Mongoid 7.3
294
+ # and earlier for backwards compatibility: in some situations, conditions
295
+ # already present in a Criteria object would be replaced by newer
296
+ # conditions when `and' method is used instead of the new conditions
297
+ # being added to the existing conditions. This would happen when using
298
+ # the same operator on the same field multiple times. For example:
295
299
#
296
300
# Band.where(id: 1).and({year: {'$in' => [2020]}}, {year: {'$in' => [2021]}}).where(id: 2)
297
301
#
@@ -305,9 +309,53 @@ for details on driver options.
305
309
#
306
310
# This is obviously incorrect as the {"$in"=>[2021]} clause is lost.
307
311
# Notice that the clause is only lost when both clauses are added using
308
- # the #and function. Turning on this feature flag fixes this bug.
309
- # (default: false)
310
- fix_multiple_ands: false
312
+ # the #and method.
313
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
314
+ broken_and: true
315
+
316
+ # When exiting a nested `with_scope' block, set the current scope to
317
+ # nil instead of the parent scope for backwards compatibility.
318
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
319
+ broken_scoping: true
320
+
321
+ # Maintain broken update behavior in some cases for backwards
322
+ # compatibility.
323
+ #
324
+ # In Mongoid 7.3 and earlier, when assigning a value to an embedded
325
+ # document, then setting it to nil, then assigning the original value
326
+ # to it again, the second update would not work and the value for the
327
+ # embedded document would remain nil. Take this case:
328
+ #
329
+ # canvas.palette = palette
330
+ # canvas.palette = nil
331
+ # canvas.palette = palette
332
+ #
333
+ # ... where canvas embeds_one palette.
334
+ #
335
+ # In Mongoid 7.3 and earlier, canvas.palette would be nil when we would
336
+ # expect it to be palette. Set this option to true to keep this behavior,
337
+ # set the option to false to perform the second update correctly.
338
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
339
+ broken_updates: true
340
+
341
+ # Time objects in Ruby have nanosecond precision, whereas MongoDB server
342
+ # can only store times with millisecond precision. Set this option to
343
+ # true to truncate times to millisecond precision when performing
344
+ # queries on already loaded embedded associations (this is also called
345
+ # "embedded matching" and is done completely in Ruby), to obtain the
346
+ # same query results when performing time comparisons regardless of
347
+ # which documents are being queried. Setting this option to false will
348
+ # produce different results for queries on embedded associations that
349
+ # are already loaded into memory vs queries on unloaded associations and
350
+ # top-level models. (default: false in Mongoid 7, will change to true
351
+ # in Mongoid 8).
352
+ compare_time_by_ms: false
353
+
354
+ # Set the global discriminator key. (default: "_type")
355
+ discriminator_key: "_type"
356
+
357
+ # Raise an exception when a field is redefined. (default: false)
358
+ duplicate_fields_exception: false
311
359
312
360
# Include the root model name in json serialization. (default: false)
313
361
include_root_in_json: false
@@ -319,6 +367,15 @@ for details on driver options.
319
367
# to parent contexts by default. (default: false)
320
368
join_contexts: false
321
369
370
+ # Maintain legacy behavior of === on Mongoid document classes, which
371
+ # returns true in a number of cases where Ruby's === implementation would
372
+ # return false. Note that the behavior of === on Mongoid document
373
+ # instances differs from both the behavior of === on document classes
374
+ # and from Ruby's behavior of === on simple object instances regardless
375
+ # of the value of this option.
376
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
377
+ legacy_triple_equals: true
378
+
322
379
# Set the Mongoid and Ruby driver log levels when Mongoid is not using
323
380
# Ruby on Rails logger instance. (default: :info)
324
381
log_level: :info
@@ -327,6 +384,12 @@ for details on driver options.
327
384
# as a BSON::Decimal128 instead of a string. (default: false)
328
385
map_big_decimal_to_decimal128: false
329
386
387
+ # Force ``BSON::ObjectId#as_json`` method to return the hash
388
+ # { "$oid" => id.to_s }. When this option is false, and bson-ruby 5
389
+ # is used, the return value will be the hexadecimal ObjectId string only.
390
+ # (default: true in Mongoid 7, will change to false in Mongoid 8)
391
+ object_id_as_json_oid: true
392
+
330
393
# Preload all models in development, needed when models use
331
394
# inheritance. (default: false)
332
395
preload_models: false
@@ -335,59 +398,15 @@ for details on driver options.
335
398
# (default: true)
336
399
raise_not_found_error: true
337
400
338
- # In Mongoid 7.3.3 and earlier, there was a bug when using with_scope
339
- # that after the function returned, any previous scopes were lost.
340
- # Turning this flag on fixes that bug. (default: false)
341
- restore_previous_scope: false
342
-
343
- # In Mongoid 7.3.3 and earlier, when doing a sum on a field with a null
344
- # context, for example:
345
- #
346
- # Product.none.sum(:price)
347
- #
348
- # the sum incorrectly returned the field name as a Symbol. Turning on
349
- # this feature flag fixes this functionality to automatically return 0.
350
- # (default: false)
351
- return_zero_on_sum_none: false
352
-
353
401
# Raise an error when defining a scope with the same name as an
354
402
# existing method. (default: false)
355
403
scope_overwrite_exception: false
356
404
357
- # Corrects === behavior to be consistent with Ruby by only calling is_a?
358
- # (default: false)
359
- triple_equals_uses_is_a: false
360
-
361
- # In Mongoid 7.3.3 and earlier, when setting an embedded document, setting
362
- # it to nil, and then setting it again to that same original value, the
363
- # second update would not work and the value for the embedded document
364
- # would remain nil. Take this case:
365
- #
366
- # canvas.palette = palette
367
- # canvas.palette = nil
368
- # canvas.palette = palette
369
- # Where canvas embeds_one palette.
370
- #
371
- # In 7.3.3 and earlier, canvas.palette would be nil when we would expect
372
- # it to be palette. Since fixing this would be a breaking change, we have
373
- # put this fix behind this feature flag. Turning this flag on fixes this
374
- # bug, and canvas.palette would contain the correct value: the assigned
375
- # palette. (default: false)
376
- update_embedded_after_nil: false
377
-
378
405
# Use ActiveSupport's time zone in time operations instead of
379
406
# the Ruby default time zone. See the time zone section below for
380
407
# further information. (default: true)
381
408
use_activesupport_time_zone: true
382
409
383
- # In Mongoid 7.3.3 and earlier, the BSON::ObjectId#as_json method would
384
- # default to returning { "$oid" => id.to_s }. Turning on this flag will
385
- # defer the as_json call to bson-ruby's implementation of
386
- # BSON::ObjectId#as_json. In bson-ruby 5.x.x as_json will return
387
- # the id as a string. In bson-ruby 4.x.x as_json will return
388
- # { "$oid" => id.to_s }. (default: false)
389
- use_bson_ruby_as_json: false
390
-
391
410
# Return stored times as UTC. See the time zone section below for
392
411
# further information. Most applications should not use this option.
393
412
# (default: false)
0 commit comments