diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2026-04-18 08:53:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-18 08:53:21 +0200 |
| commit | ed79c5959add54b6e8ea589ec601e0d2e801517e (patch) | |
| tree | 0d00f241bea6de88203d1314c7de92cb262b3a3f /django/contrib/postgres | |
| parent | d687d412a9abd9c80e31945f16ce32c020512394 (diff) | |
Fixed #37028 -- Added BitAnd(), BitOr(), and BitXor() aggregates.
Diffstat (limited to 'django/contrib/postgres')
| -rw-r--r-- | django/contrib/postgres/aggregates/general.py | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/django/contrib/postgres/aggregates/general.py b/django/contrib/postgres/aggregates/general.py index 76dc7e2633..be43e899be 100644 --- a/django/contrib/postgres/aggregates/general.py +++ b/django/contrib/postgres/aggregates/general.py @@ -1,16 +1,20 @@ import warnings from django.contrib.postgres.fields import ArrayField -from django.db.models import Aggregate, BooleanField, JSONField +from django.db.models import Aggregate +from django.db.models import BitAnd as _BitAnd +from django.db.models import BitOr as _BitOr +from django.db.models import BitXor as _BitXor +from django.db.models import BooleanField, JSONField from django.db.models import StringAgg as _StringAgg from django.db.models import Value from django.utils.deprecation import RemovedInDjango70Warning __all__ = [ "ArrayAgg", - "BitAnd", - "BitOr", - "BitXor", + "BitAnd", # RemovedInDjango70Warning + "BitOr", # RemovedInDjango70Warning + "BitXor", # RemovedInDjango70Warning "BoolAnd", "BoolOr", "JSONBAgg", @@ -28,16 +32,37 @@ class ArrayAgg(Aggregate): return ArrayField(self.source_expressions[0].output_field) -class BitAnd(Aggregate): - function = "BIT_AND" +class BitAnd(_BitAnd): + def __init__(self, expression, **extra): + warnings.warn( + "The PostgreSQL-specific BitAnd function is deprecated. Use " + "django.db.models.aggregates.BitAnd instead.", + category=RemovedInDjango70Warning, + stacklevel=2, + ) + super().__init__(expression, **extra) -class BitOr(Aggregate): - function = "BIT_OR" +class BitOr(_BitOr): + def __init__(self, expression, **extra): + warnings.warn( + "The PostgreSQL-specific BitOr function is deprecated. Use " + "django.db.models.aggregates.BitOr instead.", + category=RemovedInDjango70Warning, + stacklevel=2, + ) + super().__init__(expression, **extra) -class BitXor(Aggregate): - function = "BIT_XOR" +class BitXor(_BitXor): + def __init__(self, expression, **extra): + warnings.warn( + "The PostgreSQL-specific BitXor function is deprecated. Use " + "django.db.models.aggregates.BitXor instead.", + category=RemovedInDjango70Warning, + stacklevel=2, + ) + super().__init__(expression, **extra) class BoolAnd(Aggregate): |
