From ed79c5959add54b6e8ea589ec601e0d2e801517e Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Sat, 18 Apr 2026 08:53:21 +0200 Subject: Fixed #37028 -- Added BitAnd(), BitOr(), and BitXor() aggregates. --- docs/internals/deprecation.txt | 4 ++++ docs/ref/contrib/postgres/aggregates.txt | 15 +++++++++++++ docs/ref/models/querysets.txt | 36 ++++++++++++++++++++++++++++++++ docs/releases/6.1.txt | 14 +++++++++++++ 4 files changed, 69 insertions(+) (limited to 'docs') diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index b0d62e9879..799c355334 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -69,6 +69,10 @@ details on these changes. * The ``SQLCompiler.quote_name_unless_alias()`` method will be removed. +* The ``django.contrib.postgres.aggregates.BitAnd``, + ``django.contrib.postgres.aggregates.BitOr``, and + ``django.contrib.postgres.aggregates.BitXor`` classes will be removed. + .. _deprecation-removed-in-6.1: 6.1 diff --git a/docs/ref/contrib/postgres/aggregates.txt b/docs/ref/contrib/postgres/aggregates.txt index 040e57c5af..6381f0f7eb 100644 --- a/docs/ref/contrib/postgres/aggregates.txt +++ b/docs/ref/contrib/postgres/aggregates.txt @@ -62,6 +62,11 @@ General-purpose aggregation functions Returns an ``int`` of the bitwise ``AND`` of all non-null input values, or ``default`` if all values are null. + .. deprecated:: 6.1 + + This class is deprecated in favor of the generally available + :class:`~django.db.models.BitAnd` class. + ``BitOr`` --------- @@ -70,6 +75,11 @@ General-purpose aggregation functions Returns an ``int`` of the bitwise ``OR`` of all non-null input values, or ``default`` if all values are null. + .. deprecated:: 6.1 + + This class is deprecated in favor of the generally available + :class:`~django.db.models.BitOr` class. + ``BitXor`` ---------- @@ -78,6 +88,11 @@ General-purpose aggregation functions Returns an ``int`` of the bitwise ``XOR`` of all non-null input values, or ``default`` if all values are null. + .. deprecated:: 6.1 + + This class is deprecated in favor of the generally available + :class:`~django.db.models.BitXor` class. + ``BoolAnd`` ----------- diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 6a76fc2703..ee401a569d 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -4085,6 +4085,42 @@ by the aggregate. unique values. This is the SQL equivalent of ``AVG(DISTINCT )``. The default value is ``False``. +``BitAnd`` +~~~~~~~~~~ + +.. class:: BitAnd(expression, filter=None, default=None, **extra) + + .. versionadded:: 6.1 + + Returns an ``int`` of the bitwise ``AND`` of all non-null input values, or + ``default`` if all values are null. + + The ``default`` parameter is not supported on MariaDB, MySQL, and Oracle. + +``BitOr`` +~~~~~~~~~ + +.. class:: BitOr(expression, filter=None, default=None, **extra) + + .. versionadded:: 6.1 + + Returns an ``int`` of the bitwise ``OR`` of all non-null input values, or + ``default`` if all values are null. + + The ``default`` parameter is not supported on MariaDB, MySQL, and Oracle. + +``BitXor`` +~~~~~~~~~~ + +.. class:: BitXor(expression, filter=None, default=None, **extra) + + .. versionadded:: 6.1 + + Returns an ``int`` of the bitwise ``XOR`` of all non-null input values, or + ``default`` if all values are null. + + The ``default`` parameter is not supported on MariaDB, MySQL, and Oracle. + ``Count`` ~~~~~~~~~ diff --git a/docs/releases/6.1.txt b/docs/releases/6.1.txt index 77188e0c8e..477117c004 100644 --- a/docs/releases/6.1.txt +++ b/docs/releases/6.1.txt @@ -315,6 +315,11 @@ Models :class:`~django.db.models.query.QuerySet` is ordered and the ordering is deterministic. +* The new :class:`~django.db.models.BitAnd`, :class:`~django.db.models.BitOr`, + and :class:`~django.db.models.BitXor` aggregates return the bitwise ``AND``, + ``OR``, ``XOR``, respectively. These aggregates were previously included only + in ``contrib.postgres``. + Pagination ~~~~~~~~~~ @@ -420,6 +425,9 @@ backends. ``get_geom_placeholder_sql`` and is expected to return a two-elements tuple composed of an SQL format string and a tuple of associated parameters. +* Set the new ``DatabaseFeatures.supports_bit_aggregations`` attribute to + ``False`` if the database doesn't support bitwise aggregations. + :mod:`django.contrib.admin` --------------------------- @@ -539,6 +547,12 @@ Miscellaneous :ref:`expressions `, is deprecated in favor of the newly introduced ``quote_name()`` method. +* The ``BitAnd``, ``BitOr``, and ``BitXor`` classes in + ``django.contrib.postgres.aggregates`` are deprecated in favor of the + generally available :class:`~django.db.models.BitAnd`, + :class:`~django.db.models.BitOr`, and :class:`~django.db.models.BitXor` + classes. + Features removed in 6.1 ======================= -- cgit v1.3