11import warnings
22
33from django .contrib .postgres .fields import ArrayField
4- from django .db .models import Aggregate , BooleanField , JSONField
4+ from django .db .models import Aggregate
5+ from django .db .models import BitAnd as _BitAnd
6+ from django .db .models import BitOr as _BitOr
7+ from django .db .models import BitXor as _BitXor
8+ from django .db .models import BooleanField , JSONField
59from django .db .models import StringAgg as _StringAgg
610from django .db .models import Value
711from django .utils .deprecation import RemovedInDjango70Warning
812
913__all__ = [
1014 "ArrayAgg" ,
11- "BitAnd" ,
12- "BitOr" ,
13- "BitXor" ,
15+ "BitAnd" , # RemovedInDjango70Warning
16+ "BitOr" , # RemovedInDjango70Warning
17+ "BitXor" , # RemovedInDjango70Warning
1418 "BoolAnd" ,
1519 "BoolOr" ,
1620 "JSONBAgg" ,
@@ -28,16 +32,37 @@ def output_field(self):
2832 return ArrayField (self .source_expressions [0 ].output_field )
2933
3034
31- class BitAnd (Aggregate ):
32- function = "BIT_AND"
35+ class BitAnd (_BitAnd ):
36+ def __init__ (self , expression , ** extra ):
37+ warnings .warn (
38+ "The PostgreSQL-specific BitAnd function is deprecated. Use "
39+ "django.db.models.aggregates.BitAnd instead." ,
40+ category = RemovedInDjango70Warning ,
41+ stacklevel = 2 ,
42+ )
43+ super ().__init__ (expression , ** extra )
3344
3445
35- class BitOr (Aggregate ):
36- function = "BIT_OR"
46+ class BitOr (_BitOr ):
47+ def __init__ (self , expression , ** extra ):
48+ warnings .warn (
49+ "The PostgreSQL-specific BitOr function is deprecated. Use "
50+ "django.db.models.aggregates.BitOr instead." ,
51+ category = RemovedInDjango70Warning ,
52+ stacklevel = 2 ,
53+ )
54+ super ().__init__ (expression , ** extra )
3755
3856
39- class BitXor (Aggregate ):
40- function = "BIT_XOR"
57+ class BitXor (_BitXor ):
58+ def __init__ (self , expression , ** extra ):
59+ warnings .warn (
60+ "The PostgreSQL-specific BitXor function is deprecated. Use "
61+ "django.db.models.aggregates.BitXor instead." ,
62+ category = RemovedInDjango70Warning ,
63+ stacklevel = 2 ,
64+ )
65+ super ().__init__ (expression , ** extra )
4166
4267
4368class BoolAnd (Aggregate ):
0 commit comments