@@ -97,6 +97,18 @@ class DatabaseFeatures(BaseDatabaseFeatures):
97
97
"expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or" ,
98
98
}
99
99
100
+ _django_test_expected_failures_queryable_encryption = {
101
+ "encryption.tests.EncryptedFieldTests.test_get_encrypted_fields_map_method" ,
102
+ "encryption.tests.EncryptedFieldTests.test_get_encrypted_fields_map_command" ,
103
+ "encryption.tests.EncryptedFieldTests.test_set_encrypted_fields_map_in_client" ,
104
+ "encryption.tests.EncryptedFieldTests.test_appointment" ,
105
+ "encryption.tests.EncryptedFieldTests.test_billing" ,
106
+ "encryption.tests.EncryptedFieldTests.test_patientportaluser" ,
107
+ "encryption.tests.EncryptedFieldTests.test_patientrecord" ,
108
+ "encryption.tests.EncryptedFieldTests.test_patient" ,
109
+ "encryption.tests.EncryptedFieldTests.test_env" ,
110
+ }
111
+
100
112
@cached_property
101
113
def django_test_expected_failures (self ):
102
114
expected_failures = super ().django_test_expected_failures
@@ -569,9 +581,17 @@ def django_test_expected_failures(self):
569
581
},
570
582
}
571
583
584
+ @cached_property
585
+ def mongodb_version (self ):
586
+ return self .connection .get_database_version () # e.g., (6, 3, 0)
587
+
572
588
@cached_property
573
589
def is_mongodb_6_3 (self ):
574
- return self .connection .get_database_version () >= (6 , 3 )
590
+ return self .mongodb_version >= (6 , 3 )
591
+
592
+ @cached_property
593
+ def is_mongodb_7_0 (self ):
594
+ return self .mongodb_version >= (7 , 0 )
575
595
576
596
@cached_property
577
597
def supports_atlas_search (self ):
@@ -601,3 +621,20 @@ def _supports_transactions(self):
601
621
hello = client .command ("hello" )
602
622
# a replica set or a sharded cluster
603
623
return "setName" in hello or hello .get ("msg" ) == "isdbgrid"
624
+
625
+ @cached_property
626
+ def supports_queryable_encryption (self ):
627
+ """
628
+ Queryable Encryption is supported if the server is Atlas or Enterprise
629
+ and is configured as a replica set or a sharded cluster.
630
+ """
631
+ self .connection .ensure_connection ()
632
+ client = self .connection .connection .admin
633
+ build_info = client .command ("buildInfo" )
634
+ is_enterprise = "enterprise" in build_info .get ("modules" )
635
+ # Queryable Encryption requires transaction support which
636
+ # is only available on replica sets or sharded clusters
637
+ # which we already check in `supports_transactions`.
638
+ supports_transactions = self .supports_transactions
639
+ # TODO: check if the server is Atlas
640
+ return is_enterprise and supports_transactions and self .is_mongodb_7_0
0 commit comments