mongodb/mongoid

View on GitHub
docs/reference/compatibility.txt

Summary

Maintainability
Test Coverage
*************
Compatibility
*************

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 2
   :class: singlecol

Ruby MongoDB Driver Compatibility
=================================

The following compatibility table specifies the versions of `Ruby driver for
MongoDB <https://mongodb.com/docs/ruby-driver/current/>`_
(the ``mongo`` gem) supported by the most recent patch releases of the
specified Mongoid versions.

.. note::

  Older versions of Mongoid within the same minor release may support older
  driver versions. For example, Mongoid 7.0.5 supports driver versions 2.5 and
  newer, whereas Mongoid 7.0.6 requires driver version 2.7 or newer.

.. list-table::
   :header-rows: 1
   :stub-columns: 1
   :class: compatibility-large no-padding

   * - Mongoid
     - Driver 2.19-2.18
     - Driver 2.17-2.10
     - Driver 2.9-2.7

   * - 8.0 thru 9.0
     - |checkmark|
     -
     -

   * - 7.2 thru 7.5
     - |checkmark|
     - |checkmark|
     -

   * - 7.0 thru 7.1
     - |checkmark|
     - |checkmark|
     - |checkmark|


Ruby Compatibility
==================

The following compatibility table specifies the versions of Ruby interpreters
supported by Mongoid. "D" in a column means support for that Ruby version
is deprecated.

.. list-table::
   :header-rows: 1
   :stub-columns: 1
   :class: compatibility-large no-padding

   * - Mongoid
     - Ruby 3.2
     - Ruby 3.1
     - Ruby 3.0
     - Ruby 2.7
     - Ruby 2.6
     - Ruby 2.5
     - Ruby 2.4
     - Ruby 2.3
     - Ruby 2.2
     - JRuby 9.4
     - JRuby 9.3
     - JRuby 9.2

   * - 9.0
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     -
     -
     -
     -
     -
     - |checkmark|
     -
     -

   * - 8.1
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     -
     -
     -
     -
     -
     - |checkmark|
     -

   * - 8.0
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     -
     -
     -
     -
     -
     - |checkmark|
     -

   * - 7.5
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - D
     -
     -
     -
     -
     - |checkmark|
     - D

   * - 7.4
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     -
     -
     -
     -
     -
     - |checkmark|

   * - 7.3
     -
     - |checkmark| [#mongoid-7.3-ruby-3.0]_
     - |checkmark| [#mongoid-7.3-ruby-3.0]_
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - D
     - D
     -
     -
     -
     - |checkmark|

   * - 7.2
     -
     - |checkmark| [#mongoid-7.2-ruby-3.0]_
     - |checkmark| [#mongoid-7.2-ruby-3.0]_
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - D
     - D
     -
     -
     -
     - |checkmark|

   * - 7.1
     -
     - |checkmark| [#mongoid-7.1-ruby-3.0]_
     - |checkmark| [#mongoid-7.1-ruby-3.0]_
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark| [#ruby-2.4]_
     - |checkmark|
     -
     -
     -
     - |checkmark|

   * - 7.0
     -
     -
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark| [#ruby-2.4]_
     - |checkmark|
     - |checkmark| [#ruby-2.2]_
     -
     -
     - |checkmark|

.. [#mongoid-7.3-ruby-3.0] Mongoid version 7.3.2 or higher is required.

.. [#mongoid-7.2-ruby-3.0] Mongoid version 7.2.5 or higher is required.

.. [#mongoid-7.1-ruby-3.0] Mongoid version 7.1.10 or higher is required.

.. [#ruby-2.4] Ruby version 2.4.1 or higher is required.

.. [#ruby-2.2] Ruby version 2.2.2 or higher is required.


MongoDB Server Compatibility
============================

The following compatibility table specifies the recommended
version(s) of Mongoid for use with a specific version of MongoDB server.

Note that in order to use features of a particular MongoDB server version,
both the driver and Mongoid must support that server version.
Please refer to `the driver compatibility page
<https://mongodb.com/docs/ruby-driver/current/reference/driver-compatibility/>`_
for driver compatibility matrices.

"D" in a column means support for that MongoDB server version is deprecated
and will be removed in a next version.

.. list-table::
   :header-rows: 1
   :stub-columns: 1
   :class: compatibility-large no-padding

   * - Mongoid
     - MongoDB 7.0
     - MongoDB 6.0
     - MongoDB 5.0
     - MongoDB 4.4
     - MongoDB 4.2
     - MongoDB 4.0
     - MongoDB 3.6
     - MongoDB 3.4
     - MongoDB 3.2
     - MongoDB 3.0
     - MongoDB 2.6

   * - 8.0 thru 9.0
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     -
     -
     -
     -

   * - 7.4 thru 7.5
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - D
     - D
     - D
     - D

   * - 7.0 thru 7.3
     -
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - D
     - D
     - D
     - D


.. _rails-compatibility:

Rails Compatibility
===================

The following compatibility table specifies which versions of Ruby on Rails
are supported by Mongoid.

.. list-table::
   :header-rows: 1
   :stub-columns: 1
   :class: compatibility-large no-padding

   * - Mongoid
     - Rails 7.1
     - Rails 7.0
     - Rails 6.1
     - Rails 6.0
     - Rails 5.2
     - Rails 5.1

   * - 9.0
     - |checkmark| [#rails-7.1]_
     - |checkmark|
     - |checkmark|
     - |checkmark|
     -
     -

   * - 8.0 thru 8.1
     - |checkmark| [#rails-7.1]_
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark| [#rails-5-ruby-3.0]_
     -

   * - 7.5
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark| [#rails-5-ruby-3.0]_
     - D

   * - 7.4
     -
     - |checkmark|
     - |checkmark|
     - |checkmark|
     - |checkmark| [#rails-5-ruby-3.0]_
     - |checkmark| [#rails-5-ruby-3.0]_

   * - 7.3
     -
     - |checkmark| [#rails-7-Mongoid-7.3]_
     - |checkmark|
     - |checkmark|
     - |checkmark| [#rails-5-ruby-3.0]_
     - |checkmark| [#rails-5-ruby-3.0]_

   * - 7.2
     -
     -
     - |checkmark| [#rails-6.1]_
     - |checkmark|
     - |checkmark| [#rails-5-ruby-3.0]_
     - |checkmark| [#rails-5-ruby-3.0]_

   * - 7.1
     -
     -
     - |checkmark| [#rails-6.1]_
     - |checkmark|
     - |checkmark|
     - |checkmark|

   * - 7.0
     -
     -
     - |checkmark| [#rails-6.1]_
     - |checkmark| [#rails-6]_
     - |checkmark|
     - |checkmark|

.. [#rails-5-ruby-3.0] Using Rails 5.x with Ruby 3 is not supported.

.. [#rails-6] Rails 6.0 requires Mongoid 7.0.5 or later.

.. [#rails-6.1] Rails 6.1 requires Mongoid 7.0.12, 7.1.7 or 7.2.1 in the
  respective 7.0, 7.1 and 7.2 stable branches.

.. [#rails-7-Mongoid-7.3] Rails 7.x requires Mongoid 7.3.4 or later.

.. [#rails-7.1] Rails 7.1 requires Mongoid 8.0.7 or 8.1.3 in the respective
  8.0 and 8.1 stable branches.

.. include:: /includes/unicode-checkmark.rst
.. include:: /includes/unicode-ballot-x.rst

Rails Frameworks Support
------------------------

Ruby on Rails is comprised of a number of frameworks, which Mongoid attempts to
provide compatibility with wherever possible.

Though Mongoid attempts to offer API compatibility with `Active Record <https://guides.rubyonrails.org/active_record_basics.html>`_,
libraries that depend directly on Active Record may not work as expected when
Mongoid is used as a drop-in replacement.

.. note::

  Mongoid can be used alongside Active Record within the same application without issue.

.. list-table::
   :header-rows: 1
   :stub-columns: 1
   :class: compatibility-large no-padding

   * - Rails Framework
     - Supported?

   * - ``ActionCable``
     - |checkmark| [#rails-actioncable-dependency]_

   * - ``ActionMailbox``
     - |x| [#rails-activerecord-dependency]_

   * - ``ActionMailer``
     - |checkmark|

   * - ``ActionPack``
     - |checkmark|

   * - ``ActionText``
     - |x| [#rails-activerecord-dependency]_

   * - ``ActionView``
     - |checkmark|

   * - ``ActiveJob``
     - |checkmark| [#rails-activejob-dependency]_

   * - ``ActiveModel``
     - |checkmark| [#rails-activemodel-dependency]_

   * - ``ActiveStorage``
     - |x| [#rails-activerecord-dependency]_

   * - ``ActiveSupport``
     - |checkmark| [#rails-activesupport-dependency]_

.. [#rails-actioncable-dependency] There is currently no MongoDB adapter for
   ``ActionCable``, however any existing adapter (such as `Redis <https://guides.rubyonrails.org/action_cable_overview.html#redis-adapter>`_)
   can be used successfully in conjunction with Mongoid models

.. [#rails-activerecord-dependency] Depends directly on ``ActiveRecord``

.. [#rails-activemodel-dependency] ``Mongoid::Document`` includes ``ActiveModel::Model``
   and leverages ``ActiveModel::Validations`` for validations

.. [#rails-activesupport-dependency] ``Mongoid`` requires ``ActiveSupport`` and
   uses it extensively, including ``ActiveSupport::TimeWithZone`` for time handling.



.. [#rails-activejob-dependency] Serialization of BSON & Mongoid objects works best
   if you explicitly send ``BSON::ObjectId``'s as strings, and reconstitute them in the job:

   .. code-block:: ruby

    record = Model.find(...)
    MyJob.perform_later(record._id.to_s)

    class MyJob < ApplicationJob
      def perform(id_as_string)
        record = Model.find(id_as_string)
        # ...
      end
    end