Skip to content

Commit ce377fc

Browse files
committed
Set expect failure to tests that have get ordering issue.
1 parent fa1ab04 commit ce377fc

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

django_mongodb/compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ def build_query(self, columns=None):
359359
query.project_fields = self.get_project_fields(columns, ordering=query.ordering)
360360
try:
361361
where = getattr(self, "where", self.query.where)
362-
query.mongo_query = {"$expr": where.as_mql(self, self.connection)}
362+
query.mongo_query = (
363+
{"$expr": where.as_mql(self, self.connection)} if where is not None else {}
364+
)
363365
except FullResultSet:
364366
query.mongo_query = {}
365367
return query

django_mongodb/features.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,21 @@ class DatabaseFeatures(BaseDatabaseFeatures):
104104
"queries.test_explain.ExplainUnsupportedTests.test_message",
105105
# filter() on related model + update() doesn't work.
106106
"queries.tests.Queries5Tests.test_ticket9848",
107-
# Variance is not implemented in mongo as an aggregation,
108-
# we should transform it into StdDev * 2.
109-
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_numerical_aggregates",
110107
# Sum returns 0 instead of None in mongodb.
111108
"aggregation.test_filter_argument.FilteredAggregateTests.test_plain_annotate",
112109
"aggregation.tests.AggregateTestCase.test_aggregation_default_passed_another_aggregate",
113110
"aggregation.tests.AggregateTestCase.test_annotation_expressions",
114111
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
115112
# Manage empty result when the flag elide_empty is False
116113
"aggregation.tests.AggregateTestCase.test_empty_result_optimization",
114+
# Order is not working well for aggregates.
115+
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
116+
"aggregation.tests.AggregateTestCase.test_combine_different_types",
117+
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
118+
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
119+
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
120+
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
121+
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
117122
}
118123
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
119124
_django_test_expected_failures_bitwise = {

django_mongodb/functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def count(self, compiler, connection, **extra_context):
140140
node = self
141141
lhs_mql = process_lhs(self, compiler, connection)
142142
null_cond = {"$in": [{"$type": lhs_mql}, ["missing", "null"]]}
143-
cond = {"$cond": {"if": null_cond, "then": 0, "else": lhs_mql if self.distinct else 1}}
143+
cond = {
144+
"$cond": {"if": null_cond, "then": None, "else": lhs_mql if self.distinct else 1}
145+
}
144146
return {"$sum": cond}
145147

146148
lhs_mql = process_lhs(self, compiler, connection)

0 commit comments

Comments
 (0)