Skip to content

Commit ef4e6fd

Browse files
committed
raise exception when deletes is called with a subquery and add the skipped test.
1 parent 974b3b8 commit ef4e6fd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

django_mongodb/features.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9292
"schema.tests.SchemaTests.test_composed_constraint_with_fk",
9393
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
9494
"schema.tests.SchemaTests.test_unique_constraint",
95-
# Delete does not support subqueries.
96-
"delete_regress.tests.DeleteTests.test_self_reference_with_through_m2m_at_second_level",
9795
# Handle column default value.
9896
# https://github.com/mongodb-labs/django-mongodb/issues/155
9997
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_queryset_annotation",
@@ -396,6 +394,9 @@ def django_test_expected_failures(self):
396394
"schema.tests.SchemaTests.test_rename_column_renames_deferred_sql_references",
397395
"schema.tests.SchemaTests.test_rename_table_renames_deferred_sql_references",
398396
},
397+
"Subqueries cannot be used in delete operations": {
398+
"delete_regress.tests.DeleteTests.test_self_reference_with_through_m2m_at_second_level"
399+
},
399400
"Test executes raw SQL.": {
400401
"aggregation.tests.AggregateTestCase.test_coalesced_empty_result_set",
401402
"aggregation_regress.tests.AggregationTests.test_annotate_with_extra",

django_mongodb/query.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def __repr__(self):
6565
@wrap_database_errors
6666
def delete(self):
6767
"""Execute a delete query."""
68+
if self.compiler.subqueries:
69+
raise NotSupportedError("Subqueries are not supported in delete operations.")
6870
return self.collection.delete_many(self.mongo_query).deleted_count
6971

7072
@wrap_database_errors

0 commit comments

Comments
 (0)