============================
Django MongoDB Backend 6.0.x
============================

6.0.3
=====

*April 2, 2026*

New features
------------

- Added :ref:`support for matching ObjectIDs in URL patterns
  <object-id-in-url-patterns>`.

- Added polymorphic subfield support to
  :class:`~django_mongodb_backend.indexes.EmbeddedFieldIndex` and
  :class:`~django_mongodb_backend.constraints.EmbeddedFieldUniqueConstraint`.

  See :ref:`polymorphic-embedded-model-field-indexes`,
  :ref:`polymorphic-embedded-model-field-unique-constraints`,
  :ref:`polymorphic-embedded-model-array-field-indexes`, and
  :ref:`polymorphic-embedded-model-array-field-unique-constraints`.

- ``str(queryset.query)`` now outputs MQL instead of SQL.

Bug fixes
---------

- Made model saving raise an exception to prevent a misconfiguration from
  resulting in the creation of models with encrypted fields in non-encrypted
  databases.

- Made ``makemigrations`` serialize embedded model references as strings so
  that references in migrations don't need to be adjusted if models are later
  removed.

- Added a helpful ``NotSupportedError`` for ``QuerySet.extra(where=...)`` and
  ``StringAgg(..., distinct=True)`` rather than crashing with more obscure
  exceptions.

Deprecated features
-------------------

- Defining indexes and constraints on embedded models using ``unique=True``,
  ``db_index=True``, ``Meta.constraints``, ``Meta.indexes``, and
  ``Meta.unique_together`` is deprecated in favor of using
  :class:`~django_mongodb_backend.indexes.EmbeddedFieldIndex` and
  :class:`~django_mongodb_backend.constraints.EmbeddedFieldUniqueConstraint`
  on the top-level model. See :ref:`inline-constraints-and-indexes-deprecation`
  for an example.

6.0.2
=====

*February 5, 2026*

New features
------------

- Added support for :meth:`QuerySet.intersection()
  <django.db.models.query.QuerySet.intersection>` and
  :meth:`~django.db.models.query.QuerySet.difference`.
- Added support for :attr:`UniqueConstraint.nulls_distinct
  <django.db.models.UniqueConstraint.nulls_distinct>`. See
  :ref:`unique-constraints` for MongoDB-specific details.
- Added :class:`~django_mongodb_backend.indexes.EmbeddedFieldIndex` and
  :class:`~django_mongodb_backend.constraints.EmbeddedFieldUniqueConstraint`
  to index and create unique constraints on subfields of
  :class:`~.fields.EmbeddedModelField` and
  :class:`~.fields.EmbeddedModelArrayField`.

  See :ref:`embedded-model-field-indexes`,
  :ref:`embedded-model-field-unique-constraints`,
  :ref:`embedded-model-array-field-indexes`, and
  :ref:`embedded-model-array-field-unique-constraints`.

Bug fixes
---------

- Fixed ``Model.save()`` crash on existing models when using Queryable
  Encryption.

6.0.1
=====

*January 22, 2026*

New features
------------

- Added support for :doc:`Queryable Encryption </howto/queryable-encryption>`.
- Added support for :ref:`spatial lookups <spatial-lookups>`.

Bug fixes
---------

- Prevented ``Index`` system checks from running twice.
- Added exception messages to :class:`~django.db.DatabaseError` and
  :class:`~django.db.IntegrityError`.
- Fixed ``QuerySet.defer()`` and ``only()`` so that they project the correct
  fields. Previously, they had no effect.

Performance improvements
------------------------

- Removed usage of ``$facet`` from aggregate queries.

6.0.0
=====

*December 11, 2025*

Initial release from the state of :ref:`django-mongodb-backend 5.2.3
<django-mongodb-backend-5.2.3>`.

Regarding new features in Django 6.0, the :class:`django.db.models.StringAgg`
function isn't supported.

Backwards incompatible changes
------------------------------

- ``django_mongodb_backend.utils.parse_uri()`` is removed as per the
  :ref:`deprecation timeline <parse-uri-deprecation>`.
- The minimum supported version of MongoDB is increased from 6.0 to 7.0.
