@@ -179,7 +179,7 @@ in Mongoid 7.4 for backwards compatibility. In Mongoid 8 the default value
179179will change to ``true``.
180180
181181
182- Respect Field Aliases In Embedded Documents When Using ``distinct`` And ``pluck``
182+ Respect Field Aliases In Embedded Documents When Using ``distinct`` And ``pluck``
183183---------------------------------------------------------------------------------
184184
185185When ``distinct`` and ``pluck`` are used with aliased fields in embedded
@@ -273,10 +273,10 @@ and then to a non-nil value, for example:
273273
274274 class Canvas
275275 include Mongoid::Document
276-
276+
277277 embeds_one :palette
278278 end
279-
279+
280280 canvas.palette = palette
281281 canvas.palette = nil
282282 canvas.palette = palette
@@ -345,7 +345,7 @@ For example:
345345 Band.with_scope(active: true) do
346346 # ...
347347 end
348-
348+
349349 # {year: 2020} condition is applied here
350350 end
351351
@@ -359,11 +359,51 @@ all scopes are cleared:
359359 Band.with_scope(active: true) do
360360 # ...
361361 end
362-
362+
363363 # No scope is applied here
364364 end
365365
366366.. note::
367367
368368 The value of ``Mongoid.broken_scoping`` option will change to ``false``
369369 by default in Mongoid 8.0.
370+
371+
372+ Demongoize Values Returned from Pluck and Distinct
373+ --------------------------------------------------
374+
375+ Mongoid 7.4 with the ``Mongoid.legacy_pluck_distinct`` option set to ``false``
376+ will demongoize values returned from the pluck and distinct methods.
377+ For example:
378+
379+ .. code-block:: ruby
380+
381+ class Band
382+ include Mongoid::Document
383+
384+ field :sales, type: BigDecimal
385+ end
386+
387+ Band.create!(sales: "1E2")
388+ Band.create!(sales: "2E2")
389+ Band.pluck(:sales)
390+ # => [0.1e3, 0.2e3]
391+ Band.distinct(:sales)
392+ # => [0.1e3, 0.2e3]
393+
394+
395+ In Mongoid 7.3 and earlier, and in 7.4 with the ``Mongoid.legacy_pluck_distinct``
396+ option set to ``true`` (the default), the value returned from the pluck and
397+ distinct methods will not be demongoized. For example:
398+
399+ .. code-block:: ruby
400+
401+ Band.pluck(:sales)
402+ # => ["1E2", "2E2"]
403+ Band.distinct(:sales)
404+ # => ["1E2", "2E2"]
405+
406+ .. note::
407+
408+ The value of ``Mongoid.legacy_pluck_distinct`` option will change to ``false``
409+ by default in Mongoid 8.0.
0 commit comments