Skip to content

Commit cf49602

Browse files
committed
Organize 7.5 release notes
1 parent 0958c9a commit cf49602

File tree

1 file changed

+113
-125
lines changed

1 file changed

+113
-125
lines changed

docs/release-notes/mongoid-7.5.txt

Lines changed: 113 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -17,104 +17,54 @@ The complete list of releases is available `on GitHub
1717
please consult GitHub releases for detailed release notes and JIRA for
1818
the complete list of issues fixed in each release, including bug fixes.
1919

20-
``Array#update_values`` and ``Hash#update_values`` deprecated
21-
-------------------------------------------------------------
22-
23-
The ``Array#update_values`` and ``Hash#update_values`` methods are deprecated in
24-
Mongoid 7.5. It is recommended to use ActiveSupport's ``transform_values!``
25-
method instead.
26-
27-
28-
Ruby 2.5 Deprecated
29-
-------------------
30-
31-
Mongoid 7.5 deprecates support for Ruby 2.5.
32-
Mongoid 8 will require Ruby 2.6 or newer.
33-
34-
35-
JRuby 9.2 Deprecated
36-
--------------------
37-
38-
Mongoid 7.5 deprecates support for JRuby 9.2.
39-
Mongoid 8 will require JRuby 9.3 or newer.
40-
41-
42-
Rails 5.1 Deprecated
43-
--------------------
44-
45-
Mongoid 7.5 deprecates support for Rails 5.1.
46-
Mongoid 8 will require Rails 5.2 or newer.
47-
48-
49-
``Document#to_a`` deprecated
50-
----------------------------
51-
52-
The ``Document#to_a`` method is deprecated in Mongoid 7.5.
53-
54-
55-
Combine Chained Operators Using ``and`` Instead of ``override``
56-
---------------------------------------------------------------
57-
58-
Mongoid 7.5 with the ``Mongoid.overwrite_chained_operators`` option set to ``false``
59-
will combine conditions that use the same operator and field using an ``and``.
60-
For example, in the following query:
61-
62-
.. code-block:: ruby
6320

64-
Band.ne(name: "The Rolling Stones").ne(name: "The Beatles")
21+
Ruby, JRuby and Rails Version Support
22+
-------------------------------------
6523

66-
Mongoid 7.5 with the ``Mongoid.overwrite_chained_operators`` option set to ``false``
67-
will generate the following criteria:
24+
Mongoid 7.5 deprecates support for Ruby 2.5, JRuby 9.2 and Rails 5.1.
25+
Mongoid 8 will requir Ruby 2.6 or newer, JRuby 9.3 or newer and Rails 5.2 or
26+
newer.
6827

69-
.. code-block:: ruby
7028

71-
#<Mongoid::Criteria
72-
selector: {"name"=>{"$ne"=>"The Rolling Stones"}, "$and"=>[{"name"=>{"$ne"=>"The Beatles"}}]}
73-
options: {}
74-
class: Band
75-
embedded: false>
29+
Implemented ``Criteria#take/take!`` Method
30+
------------------------------------------
7631

77-
In Mongoid 7.4 and earlier, and in 7.5 with the ``Mongoid.overwrite_chained_operators``
78-
option set to ``true``, the following criteria would be generated instead which
79-
overwrites the first condition:
32+
Mongoid 7.5 introduces the ``#take`` method which returns a document
33+
or a set of documents from the database without ordering by ``_id``:
8034

81-
.. code-block:: ruby
35+
.. code:: ruby
8236

83-
#<Mongoid::Criteria
84-
selector: {"name"=>{"$ne"=>"The Beatles"}}
85-
options: {}
86-
class: Band
87-
embedded: false>
37+
class Band
38+
include Mongoid::Document
39+
end
8840

89-
The following functions are affected by this change:
41+
Band.create!
42+
Band.create!
9043

91-
- ``eq``
92-
- ``elem_match``
93-
- ``gt``
94-
- ``gte``
95-
- ``lt``
96-
- ``lte``
97-
- ``mod``
98-
- ``ne``
99-
- ``near``
100-
- ``near_sphere``
44+
Band.take
45+
# => #<Band _id: 62c835813282a4470c07d530, >
46+
Band.take(2)
47+
# => [ #<Band _id: 62c835813282a4470c07d530, >, #<Band _id: 62c835823282a4470c07d531, > ]
10148

102-
.. note::
49+
If a parameter is given to ``#take``, an array of documents is returned. If no parameter is
50+
given, a singular document is returned.
10351

104-
In Mongoid 7.5 with the ``Mongoid.overwrite_chained_operators`` option set to
105-
``false``, nested keys in the generated selector will always be strings,
106-
whereas in Mongoid 7.4 and earlier, and in 7.5 with the
107-
``Mongoid.overwrite_chained_operators`` option set to ``true``, nested keys in
108-
the selector can be strings or symbols, depending on what was passed to the
109-
operator.
52+
The ``#take!`` method functions the same as calling ``#take`` without arguments,
53+
but raises an DocumentNotFound error instead of returning nil if no documents
54+
are found.
11055

56+
.. code:: ruby
11157

112-
``update_one`` Warnings in ``upsert``
113-
-------------------------------------
58+
Band.take!
59+
# => #<Band _id: 62c835813282a4470c07d530, >
11460

115-
Mongoid 7.5 fixes incorrect usage of the driver's ``update_one`` method from
116-
Mongoid's ``upsert`` method. Mongoid's ``upsert`` actually performs a
117-
replacing upsert, and Mongoid 7.5 correctly calls ``replace_one``.
61+
Note that the ``#take/take!`` methods do not apply a sort to the view before
62+
retrieving the documents from the database, and therefore they may return different
63+
results than the ``#first`` and ``#last`` methods. ``#take`` is equivalent to
64+
calling ``#first`` or ``#last`` with the ``{ id_sort: :none }`` option. This
65+
option has been deprecated in Mongoid 7.5 and it is recommended to use ``#take``
66+
instead going forward. Support for the ``:id_sort`` option will be dropped in
67+
Mongoid 8.
11868

11969

12070
Force the ``attributes`` Method to Always Return a ``Hash``
@@ -156,47 +106,6 @@ return a ``Hash`` when instantiating a new document:
156106
# => BSON::Document
157107

158108

159-
Implemented ``Criteria#take/take!`` Method
160-
------------------------------------------
161-
162-
Mongoid 7.5 introduces the ``#take`` method which returns a document
163-
or a set of documents from the database without ordering by ``_id``:
164-
165-
.. code:: ruby
166-
167-
class Band
168-
include Mongoid::Document
169-
end
170-
171-
Band.create!
172-
Band.create!
173-
174-
Band.take
175-
# => #<Band _id: 62c835813282a4470c07d530, >
176-
Band.take(2)
177-
# => [ #<Band _id: 62c835813282a4470c07d530, >, #<Band _id: 62c835823282a4470c07d531, > ]
178-
179-
If a parameter is given to ``#take``, an array of documents is returned. If no parameter is
180-
given, a singular document is returned.
181-
182-
The ``#take!`` method functions the same as calling ``#take`` without arguments,
183-
but raises an DocumentNotFound error instead of returning nil if no documents
184-
are found.
185-
186-
.. code:: ruby
187-
188-
Band.take!
189-
# => #<Band _id: 62c835813282a4470c07d530, >
190-
191-
Note that the ``#take/take!`` methods do not apply a sort to the view before
192-
retrieving the documents from the database, and therefore they may return different
193-
results than the ``#first`` and ``#last`` methods. ``#take`` is equivalent to
194-
calling ``#first`` or ``#last`` with the ``{ id_sort: :none }`` option. This
195-
option has been deprecated in Mongoid 7.5 and it is recommended to use ``#take``
196-
instead going forward. Support for the ``:id_sort`` option will be dropped in
197-
Mongoid 8.
198-
199-
200109
Deprecate ``:id_sort`` Option and Support ``limit`` on ``#first/last``
201110
----------------------------------------------------------------------
202111

@@ -231,6 +140,63 @@ cause performance issues. To get a document without sorting first, use the
231140
``Critera#take`` method.
232141

233142

143+
Combine Chained Operators Using ``and`` Instead of ``override``
144+
---------------------------------------------------------------
145+
146+
Mongoid 7.5 with the ``Mongoid.overwrite_chained_operators`` option set to ``false``
147+
will combine conditions that use the same operator and field using an ``and``.
148+
For example, in the following query:
149+
150+
.. code-block:: ruby
151+
152+
Band.ne(name: "The Rolling Stones").ne(name: "The Beatles")
153+
154+
Mongoid 7.5 with the ``Mongoid.overwrite_chained_operators`` option set to ``false``
155+
will generate the following criteria:
156+
157+
.. code-block:: ruby
158+
159+
#<Mongoid::Criteria
160+
selector: {"name"=>{"$ne"=>"The Rolling Stones"}, "$and"=>[{"name"=>{"$ne"=>"The Beatles"}}]}
161+
options: {}
162+
class: Band
163+
embedded: false>
164+
165+
In Mongoid 7.4 and earlier, and in 7.5 with the ``Mongoid.overwrite_chained_operators``
166+
option set to ``true``, the following criteria would be generated instead which
167+
overwrites the first condition:
168+
169+
.. code-block:: ruby
170+
171+
#<Mongoid::Criteria
172+
selector: {"name"=>{"$ne"=>"The Beatles"}}
173+
options: {}
174+
class: Band
175+
embedded: false>
176+
177+
The following functions are affected by this change:
178+
179+
- ``eq``
180+
- ``elem_match``
181+
- ``gt``
182+
- ``gte``
183+
- ``lt``
184+
- ``lte``
185+
- ``mod``
186+
- ``ne``
187+
- ``near``
188+
- ``near_sphere``
189+
190+
.. note::
191+
192+
In Mongoid 7.5 with the ``Mongoid.overwrite_chained_operators`` option set to
193+
``false``, nested keys in the generated selector will always be strings,
194+
whereas in Mongoid 7.4 and earlier, and in 7.5 with the
195+
``Mongoid.overwrite_chained_operators`` option set to ``true``, nested keys in
196+
the selector can be strings or symbols, depending on what was passed to the
197+
operator.
198+
199+
234200
``Mongoid::Criteria`` cache deprecated
235201
--------------------------------------
236202

@@ -239,3 +205,25 @@ The ability to cache individual criteria objects has been deprecated in Mongoid
239205

240206
In order to get caching functionality, enable the Mongoid QueryCache. See the
241207
section on :ref:`QueryCache <query-cache>` for more details.
208+
209+
210+
``Array#update_values`` and ``Hash#update_values`` deprecated
211+
-------------------------------------------------------------
212+
213+
The ``Array#update_values`` and ``Hash#update_values`` methods are deprecated in
214+
Mongoid 7.5. It is recommended to use ActiveSupport's ``transform_values!``
215+
method instead.
216+
217+
218+
``Document#to_a`` deprecated
219+
----------------------------
220+
221+
The ``Document#to_a`` method is deprecated in Mongoid 7.5.
222+
223+
224+
``update_one`` Warnings in ``upsert``
225+
-------------------------------------
226+
227+
Mongoid 7.5 fixes incorrect usage of the driver's ``update_one`` method from
228+
Mongoid's ``upsert`` method. Mongoid's ``upsert`` actually performs a
229+
replacing upsert, and Mongoid 7.5 correctly calls ``replace_one``.

0 commit comments

Comments
 (0)