Skip to content

add skips for one_to_one tests #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
m2m_through
m2o_recursive
model_fields
one_to_one
ordering
or_lookups
queries.tests.Ticket12807Tests.test_ticket_12807
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Migrations for 'admin':
- `aggregate()`
- `dates()`
- `datetimes()`
- `delete()`, if the query uses multiple collections.
- `distinct()`
- `extra()`
- `prefetch_related()`
Expand Down
9 changes: 8 additions & 1 deletion django_mongodb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,19 @@ def insert(self, docs, returning_fields=None):
return inserted_ids if returning_fields else []


class SQLDeleteCompiler(SQLCompiler):
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler):
def execute_sql(self, result_type=MULTI):
cursor = Cursor()
cursor.rowcount = self.build_query([self.query.get_meta().pk]).delete()
return cursor

def check_query(self):
super().check_query()
if not self.single_alias:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single_alias comes from compiler.SQLDeleteCompiler.

raise NotSupportedError(
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB."
)


class SQLUpdateCompiler(SQLCompiler):
def execute_sql(self, result_type):
Expand Down
8 changes: 8 additions & 0 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"annotations.tests.AliasTests.test_order_by_alias",
# annotate() + values_list() + order_by() loses annotated value.
"expressions_case.tests.CaseExpressionTests.test_annotate_values_not_in_order_by",
# Querying the reverse side of a foreign key for None returns no
# results: https://github.com/mongodb-labs/django-mongodb/issues/76
"one_to_one.tests.OneToOneTests.test_filter_one_to_one_relations",
}
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
_django_test_expected_failures_bitwise = {
Expand Down Expand Up @@ -353,6 +356,8 @@ def django_test_expected_failures(self):
"lookup.tests.LookupTests.test_exact_sliced_queryset_limit_one_offset",
"lookup.tests.LookupTests.test_in_different_database",
"model_fields.test_jsonfield.TestQuerying.test_usage_in_subquery",
"one_to_one.tests.OneToOneTests.test_get_prefetch_queryset_warning",
"one_to_one.tests.OneToOneTests.test_rel_pk_subquery",
},
"Count doesn't work in QuerySet.annotate()": {
"annotations.tests.AliasTests.test_alias_annotate_with_aggregation",
Expand All @@ -361,6 +366,9 @@ def django_test_expected_failures(self):
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_with_aggregation",
"db_functions.comparison.test_cast.CastTests.test_cast_from_db_datetime_to_date_group_by",
},
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB.": {
"one_to_one.tests.OneToOneTests.test_o2o_primary_key_delete",
},
"QuerySet.dates() is not supported on MongoDB.": {
"annotations.tests.AliasTests.test_dates_alias",
"dates.tests.DatesTests.test_dates_trunc_datetime_fields",
Expand Down