Skip to content

Commit 8d458e9

Browse files
MONGOID-5721 - Update documentation and tests to remove references to MongoDB server 3.4 and prior (#5762)
1 parent 0ab88b9 commit 8d458e9

File tree

21 files changed

+45
-173
lines changed

21 files changed

+45
-173
lines changed

docs/reference/associations.txt

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -693,30 +693,22 @@ Querying Loaded Associations
693693
````````````````````````````
694694

695695
Mongoid query methods can be used on embedded associations of documents which
696-
are already loaded in the application. This mechanism is sometimes called
697-
"embedded matching" or "embedded document matching" and it is implemented
698-
entirely in Mongoid - the queries are NOT sent to the server.
699-
700-
Embedded matching is supported for most general-purpose query operators. It
701-
is not implemented for :ref:`text search <text-search>`, :manual:`geospatial query
702-
operators </reference/operator/query-geospatial/>`,
703-
operators that execute JavaScript code (:manual:`$where </reference/operator/query/where/>`)
704-
and operators that are implemented via other server functionality such as
705-
:manual:`$expr <https://mongodb.com/docs/manual/reference/operator/query/expr/>`
706-
and :manual:`$jsonSchema <https://mongodb.com/docs/manual/reference/operator/query/jsonSchema/>`.
696+
are already loaded in the application. This mechanism is called
697+
"embedded matching" and it is implemented entirely in Mongoid--the queries
698+
are NOT sent to the server.
707699

708700
The following operators are supported:
709701

710-
- :manual:`Bitwise operators </reference/operator/query-bitwise/>`
711702
- :manual:`Comparison operators </reference/operator/query-comparison/>`
712703
- :manual:`Logical operators </reference/operator/query-logical/>`
713-
- :manual:`$comment </reference/operator/query/comment/>`
704+
- :manual:`Array query operators </reference/operator/query-array/>`
714705
- :manual:`$exists </reference/operator/query/exists/>`
715706
- :manual:`$mod </reference/operator/query/mod/>`
716707
- :manual:`$type </reference/operator/query/type/>`
717708
- :manual:`$regex </reference/operator/query/regex/>` (``$options`` field
718709
is only supported when the ``$regex`` argument is a string)
719-
- :manual:`Array query operators </reference/operator/query-array/>`
710+
- :manual:`Bitwise operators </reference/operator/query-bitwise/>`
711+
- :manual:`$comment </reference/operator/query/comment/>`
720712

721713
For example, using the model definitions just given, we could query
722714
tours on a loaded band:
@@ -726,33 +718,19 @@ tours on a loaded band:
726718
band = Band.where(name: 'Astral Projection').first
727719
tours = band.tours.where(year: {'$gte' => 2000})
728720

729-
Embedded Matching Vs Server Behavior
721+
Embedded Matching vs Server Behavior
730722
````````````````````````````````````
731723

732-
Mongoid aims to provide the same semantics when performing embedded matching
733-
as those of MongoDB server. This means, for example, when the server only
734-
accepts arguments of particular types for a particular operator, Mongoid
735-
would also only accept arguments of the corresponding types.
736-
737-
The following deviations are known:
738-
739-
- Mongoid embedded matchers, because they are implemented on the client side,
740-
behave the same regardless of the server version that backs the application.
741-
As such, it is possible for Mongoid to deviate from server behavior if
742-
the server itself behaves differently in different versions. All operators are implemented in
743-
Mongoid regardless of backing deployment's server version.
744-
745-
As of this writing, the known cases of such deviation are:
746-
747-
- 3.2 and earlier servers not validating ``$size`` arguments as strictly as newer versions do.
748-
- 4.0 and earlier servers not validating ``$type`` arguments as strictly as newer versions
749-
do (allowing invalid arguments like 0, for example).
750-
- 3.2 and earlier servers not supporting ``Decimal128`` for ``$type``, as well as allowing invalid
751-
arguments such as negative numbers (smaller than -1) and numbers that are greater than 19
752-
(not including 127, the argument for the ``MaxKey`` type).
753-
- 3.4 and earlier servers not supporting arrays for ``$type``.
754-
- 3.0 and earlier servers not supporting bitwise operators.
724+
Mongoid's embedded matching aims to support the same functionality and
725+
semantics as native queries on the latest MongoDB server version.
726+
Note the following known limitations:
755727

728+
- Embedded matching is not implemented for :ref:`text search <text-search>`,
729+
:manual:`geospatial query operators </reference/operator/query-geospatial/>`,
730+
operators that execute JavaScript code (:manual:`$where </reference/operator/query/where/>`)
731+
and operators that are implemented via other server functionality such as
732+
:manual:`$expr <https://mongodb.com/docs/manual/reference/operator/query/expr/>`
733+
and :manual:`$jsonSchema <https://mongodb.com/docs/manual/reference/operator/query/jsonSchema/>`.
756734

757735
- Mongoid DSL expands ``Range`` arguments to hashes with ``$gte`` and ``$lte``
758736
conditions. `In some cases <https://jira.mongodb.org/browse/MONGOID-4908>`_
@@ -764,7 +742,9 @@ The following deviations are known:
764742
possible <https://jira.mongodb.org/browse/MONGOID-4936>`_ to specify a
765743
regular expression object as the pattern and also provide options.
766744

767-
In general, Mongoid adopts the behavior of current server versions and validates more strictly.
745+
- MongoDB Server 4.0 and earlier servers do not validate ``$type`` arguments strictly
746+
(for example, allowing invalid arguments like 0). This is validated more strictly on
747+
the client side.
768748

769749

770750
.. _omit-id:

docs/reference/configuration.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ for details on driver options.
171171
# roles:
172172
# - 'dbOwner'
173173

174-
# Change the default authentication mechanism. Valid options are: :scram,
175-
# :mongodb_cr, :mongodb_x509, and :plain. Note that all authentication
176-
# mechanisms require username and password, with the exception of :mongodb_x509.
177-
# Default is :scram since MongoDB 3.0; earlier versions defaulted to :plain.
174+
# Change the default authentication mechanism. Valid options include:
175+
# :scram, :scram256, :mongodb_cr, :mongodb_x509, :gssapi, :aws, :plain.
176+
# MongoDB Server defaults to :scram, which will use "SCRAM-SHA-256" if available,
177+
# otherwise fallback to "SCRAM-SHA-1" (:scram256 will always use "SCRAM-SHA-256".)
178+
# This setting is handled by the MongoDB Ruby Driver. Please refer to:
179+
# https://mongodb.com/docs/ruby-driver/current/reference/authentication/
178180
# auth_mech: :scram
179181

180182
# The database or source to authenticate the user against.
@@ -263,10 +265,10 @@ for details on driver options.
263265
# the setting is ignored.
264266
# allow_bson5_decimal128: false
265267

266-
# Application name that is printed to the mongodb logs upon establishing
267-
# a connection in server versions >= 3.4. Note that the name cannot
268-
# exceed 128 bytes. It is also used as the database name if the
269-
# database name is not explicitly defined.
268+
# Application name that is printed to the MongoDB logs upon establishing
269+
# a connection. Note that the name cannot exceed 128 bytes in length.
270+
# It is also used as the database name if the database name is not
271+
# explicitly defined. (default: nil)
270272
# app_name: nil
271273

272274
# When this flag is false, callbacks for embedded documents will not be
@@ -280,7 +282,7 @@ for details on driver options.
280282
# around_callbacks_for_embeds: false
281283

282284
# Sets the async_query_executor for the application. By default the thread pool executor
283-
# is set to `:immediate. Options are:
285+
# is set to `:immediate`. Options are:
284286
#
285287
# - :immediate - Initializes a single +Concurrent::ImmediateExecutor+
286288
# - :global_thread_pool - Initializes a single +Concurrent::ThreadPoolExecutor+

docs/reference/queries.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,7 @@ Mongoid also has some helpful methods on criteria.
14221422
*Find documents for a provided JavaScript expression, optionally with
14231423
the specified variables added to the evaluation scope. The scope
14241424
argument is supported in MongoDB 4.2 and lower.*
1425-
*In MongoDB 3.6 and higher, prefer* :manual:`$expr
1426-
</reference/operator/query/expr/>` *over* ``for_js``.
1425+
*Prefer* :manual:`$expr </reference/operator/query/expr/>` *over* ``for_js``.
14271426

14281427
-
14291428
.. code-block:: ruby

docs/reference/sessions.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ Sessions
1212
:depth: 2
1313
:class: singlecol
1414

15-
Versions 3.6 and higher of the MongoDB server support sessions. You can use sessions with Mongoid in a similar way
16-
that you would execute a transaction in ActiveRecord. Namely, you can call a method, ``#with_session`` on a model class
17-
or on an instance of a model and execute some operations in a block. All operations in the block will be
18-
executed in the context of single session. Please see the MongoDB Ruby driver documentation for what session options
19-
are available.
15+
You can use sessions with Mongoid in a similar way that you would execute a transaction in ActiveRecord.
16+
Namely, you can call a method, ``#with_session`` on a model class or on an instance of a model and execute
17+
some operations in a block. All operations in the block will be executed in the context of single session.
18+
Please see the MongoDB Ruby driver documentation for what session options are available.
2019

2120
Please note the following limitations of sessions:
2221

@@ -26,8 +25,6 @@ Please note the following limitations of sessions:
2625

2726
- All model classes and instances used within the session block must use the same driver client. For example, if you have specified different ``storage_options`` for another model used in the block than that of the model class or instance on which ``#with_session`` is called, you will get an error.
2827

29-
- All connected MongoDB servers must be version 3.6 or higher.
30-
3128
Using a Session via Model#with_session
3229
======================================
3330

lib/mongoid/config.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ module Config
2323

2424
LOCK = Mutex.new
2525

26-
# Application name that is printed to the mongodb logs upon establishing
27-
# a connection in server versions >= 3.4. Note that the name cannot
28-
# exceed 128 bytes. It is also used as the database name if the
29-
# database name is not explicitly defined.
26+
# Application name that is printed to the MongoDB logs upon establishing
27+
# a connection. Note that the name cannot exceed 128 bytes in length.
28+
# It is also used as the database name if the database name is not
29+
# explicitly defined.
3030
option :app_name, default: nil
3131

3232
# (Deprecated) In MongoDB 4.0 and earlier, set whether to create

lib/rails/generators/mongoid/config/templates/mongoid.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ development:
4141
# roles:
4242
# - 'dbOwner'
4343

44-
# Change the default authentication mechanism. Valid options are: :scram,
45-
# :mongodb_cr, :mongodb_x509, and :plain. Note that all authentication
46-
# mechanisms require username and password, with the exception of :mongodb_x509.
47-
# Default is :scram since MongoDB 3.0; earlier versions defaulted to :plain.
44+
# Change the default authentication mechanism. Valid options include:
45+
# :scram, :scram256, :mongodb_cr, :mongodb_x509, :gssapi, :aws, :plain.
46+
# MongoDB Server defaults to :scram, which will use "SCRAM-SHA-256" if available,
47+
# otherwise fallback to "SCRAM-SHA-1" (:scram256 will always use "SCRAM-SHA-256".)
48+
# This setting is handled by the MongoDB Ruby Driver. Please refer to:
49+
# https://mongodb.com/docs/ruby-driver/current/reference/authentication/
4850
# auth_mech: :scram
4951

5052
# The database or source to authenticate the user against.

spec/integration/matcher_operator_data/bits_all_clear.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
a:
77
$bitsAllClear: 35
88
matches: true
9-
min_server_version: 3.2
109

1110
- name: existing field - does not match with int
1211
document:
@@ -16,7 +15,6 @@
1615
a:
1716
$bitsAllClear: 24
1817
matches: false
19-
min_server_version: 3.2
2018

2119
- name: existing field - matches with binData
2220
document:
@@ -29,7 +27,6 @@
2927
IW==
3028
type: :generic
3129
matches: true
32-
min_server_version: 3.2
3330

3431
- name: existing field - does not match with binData
3532
document:
@@ -42,7 +39,6 @@
4239
IW==
4340
type: :generic
4441
matches: false
45-
min_server_version: 3.2
4642

4743
- name: existing binData field matches
4844
document:
@@ -54,7 +50,6 @@
5450
a:
5551
$bitsAllClear: 20
5652
matches: true
57-
min_server_version: 3.2
5853

5954
- name: existing binData field does not match
6055
document:
@@ -66,7 +61,6 @@
6661
a:
6762
$bitsAllClear: 15
6863
matches: false
69-
min_server_version: 3.2
7064

7165
- name: existing field - matches with array
7266
document:
@@ -76,7 +70,6 @@
7670
a:
7771
$bitsAllClear: [0, 3]
7872
matches: true
79-
min_server_version: 3.2
8073

8174
- name: existing field - does not match with array
8275
document:
@@ -86,7 +79,6 @@
8679
a:
8780
$bitsAllClear: [0, 2]
8881
matches: false
89-
min_server_version: 3.2
9082

9183
- name: float condition representable as an integer
9284
document:
@@ -96,7 +88,6 @@
9688
a:
9789
$bitsAllClear: 35.0
9890
matches: true
99-
min_server_version: 3.2
10091

10192
- name: float condition not representable as an integer
10293
document:
@@ -106,7 +97,6 @@
10697
a:
10798
$bitsAllClear: 35.1
10899
error: true
109-
min_server_version: 3.2
110100

111101
- name: string condition
112102
document:
@@ -116,7 +106,6 @@
116106
a:
117107
$bitsAllClear: hello
118108
error: true
119-
min_server_version: 3.2
120109

121110
- name: empty array condition
122111
document:
@@ -126,7 +115,6 @@
126115
a:
127116
$bitsAllClear: []
128117
matches: true
129-
min_server_version: 3.2
130118

131119
- name: integer 0 condition
132120
document:
@@ -136,7 +124,6 @@
136124
a:
137125
$bitsAllClear: 0
138126
matches: true
139-
min_server_version: 3.2
140127

141128
- name: negative integer condition
142129
document:
@@ -146,7 +133,6 @@
146133
a:
147134
$bitsAllClear: -1
148135
error: true
149-
min_server_version: 3.2
150136

151137
- name: negative float condition
152138
document:
@@ -156,4 +142,3 @@
156142
a:
157143
$bitsAllClear: -1.0
158144
error: true
159-
min_server_version: 3.2

0 commit comments

Comments
 (0)