1
1
from django .db .backends .base .features import BaseDatabaseFeatures
2
+ from django .utils .functional import cached_property
2
3
3
4
4
5
class DatabaseFeatures (BaseDatabaseFeatures ):
@@ -17,7 +18,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
17
18
supports_transactions = False
18
19
uses_savepoints = False
19
20
20
- django_test_expected_failures = {
21
+ _django_test_expected_failures = {
21
22
# Database defaults not supported: bson.errors.InvalidDocument:
22
23
# cannot encode object: <django.db.models.expressions.DatabaseDefault
23
24
"basic.tests.ModelInstanceCreationTests.test_save_primary_with_db_default" ,
@@ -60,6 +61,23 @@ class DatabaseFeatures(BaseDatabaseFeatures):
60
61
# Length of null considered zero rather than null.
61
62
"db_functions.text.test_length.LengthTests.test_basic" ,
62
63
}
64
+ # $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
65
+ _django_test_expected_failures_bitwise = {
66
+ "expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_and" ,
67
+ "expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_or" ,
68
+ "expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor" ,
69
+ "expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_null" ,
70
+ "expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_right_null" ,
71
+ "expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or" ,
72
+ }
73
+
74
+ @cached_property
75
+ def django_test_expected_failures (self ):
76
+ expected_failures = super ().django_test_expected_failures
77
+ expected_failures .update (self ._django_test_expected_failures )
78
+ if not self .is_mongodb_6_3 :
79
+ expected_failures .update (self ._django_test_expected_failures_bitwise )
80
+ return expected_failures
63
81
64
82
django_test_skips = {
65
83
"Insert expressions aren't supported." : {
@@ -336,3 +354,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
336
354
"db_functions.comparison.test_cast.CastTests.test_cast_to_duration" ,
337
355
},
338
356
}
357
+
358
+ @cached_property
359
+ def is_mongodb_6_3 (self ):
360
+ return self .connection .get_database_version () >= (6 , 3 )
0 commit comments