Skip to content

Commit 6fea834

Browse files
ksadoffp
andauthored
MONGOID-4906 Implement $type (#4923)
* separated type * added all tests except for Date and Decimal128 * fixed decimal128 and date * checking evergreen results * added min server versions * added min server version for decimal, too large/negative, and array argument * code review feedback * add trailing comma * separate $type tests by type * simplify array test * expand boolean tests * expand code and code with scope tests * expand decimal coverage * simplify double tests * allow Ruby integers to satisfy int32 matcher * allow Ruby integers to satisfy int64 matcher * fix null $type when field does not exist * expand tests * expand tests * simplify string test * expand symbol coverage * add a timestamp test case * expand regexp test coverage * support multiple array elements in $type * flip the files * added release notes * fixing release notes * fixing release notes * fixing release notes * fixing release notes * fixing release notes * fixing release notes * added list of deviations * add missing server version constraint * fix newlines * specify which operators were added Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent efb9281 commit 6fea834

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

source/tutorials/mongoid-relations.txt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,19 @@ operators that execute JavaScript code (:manual:`$where </reference/operator/que
639639
and operators that are implemented via other server functionality such as
640640
:manual:`$expr <https://docs.mongodb.com/manual/reference/operator/query/expr/>`
641641
and :manual:`$jsonSchema <https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/>`.
642+
642643
The following operators are supported:
643644

644-
- :manual:`Comparison operators </reference/operator/query-comparison/>`.
645-
- :manual:`Logical operators </reference/operator/query-logical/>`.
645+
- :manual:`Bitwise operators </reference/operator/query-bitwise/>`
646+
- :manual:`Comparison operators </reference/operator/query-comparison/>`
647+
- :manual:`Logical operators </reference/operator/query-logical/>`
648+
- :manual:`$comment </reference/operator/query/comment/>`
646649
- :manual:`$exists </reference/operator/query/exists/>`
647-
(:manual:`$type </reference/operator/query/type/>` is not currently supported).
650+
- :manual:`$mod </reference/operator/query/mod/>`
651+
- :manual:`$type </reference/operator/query/type/>`
648652
- :manual:`$regex </reference/operator/query/regex/>` (``$options`` field
649-
is only supported when the ``$regex`` argument is a string).
650-
- :manual:`Array query operators </reference/operator/query-array/>`.
653+
is only supported when the ``$regex`` argument is a string)
654+
- :manual:`Array query operators </reference/operator/query-array/>`
651655

652656
For example, using the model definitions just given, we could query
653657
tours on a loaded band:
@@ -670,12 +674,20 @@ The following deviations are known:
670674
- Mongoid embedded matchers, because they are implemented on the client side,
671675
behave the same regardless of the server version that backs the application.
672676
As such, it is possible for Mongoid to deviate from server behavior if
673-
the server itself behaves differently in different versions.
677+
the server itself behaves differently in different versions. All operators are implemented in
678+
Mongoid regardless of backing deployment's server version.
674679

675-
As of this writing, the only known case of such deviation is 3.2 and
676-
earlier servers not validating ``$size`` arguments as strictly as
677-
newer versions do. Mongoid adopts the behavior of current server versions
678-
and validates more strictly.
680+
As of this writing, the known cases of such deviation are:
681+
682+
- 3.2 and earlier servers not validating ``$size`` arguments as strictly as newer versions do.
683+
- 4.0 and earlier servers not validating ``$type`` arguments as strictly as newer versions
684+
do (allowing invalid arguments like 0, for example).
685+
- 3.2 and earlier servers not supporting ``Decimal128`` for ``$type``, as well as allowing invalid
686+
arguments such as negative numbers (smaller than -1) and numbers that are greater than 19
687+
(not including 127, the argument for the ``MaxKey`` type).
688+
- 3.4 and earlier servers not supporting arrays for ``$type``.
689+
- 3.0 and earlier servers not supporting bitwise operators.
690+
679691

680692
- Mongoid DSL expands ``Range`` arguments to hashes with ``$gte`` and ``$lte``
681693
conditions. `In some cases <https://jira.mongodb.org/browse/MONGOID-4908>`_
@@ -687,6 +699,8 @@ The following deviations are known:
687699
possible <https://jira.mongodb.org/browse/MONGOID-4936>`_ to specify a
688700
regular expression object as the pattern and also provide options.
689701

702+
In general, Mongoid adopts the behavior of current server versions and validates more strictly.
703+
690704

691705
Common Behavior
692706
===============

source/tutorials/mongoid-upgrade.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ conditions.
349349
# Mongoid 7.2 and 7.1:
350350
# => #<Task _id: 5ef8dc3e2c97a645ec86bb33, name: "Clean house", pattern: /test/, hours: 12>
351351

352+
Additional Supported Operators
353+
``````````````````````````````
354+
355+
Mongoid 7.2 adds support for bitwise operators, ``$comment``, ``$mod`` and
356+
``$type`` operators when embedded matching.
357+
352358

353359
``count`` and ``estimated_count`` Methods
354360
-----------------------------------------

0 commit comments

Comments
 (0)