Skip to content

Commit b9ae31b

Browse files
committed
Set expect failure to tests that have get ordering issue.
1 parent 194e290 commit b9ae31b

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
@@ -107,16 +107,21 @@ class DatabaseFeatures(BaseDatabaseFeatures):
107107
"queries.test_explain.ExplainUnsupportedTests.test_message",
108108
# filter() on related model + update() doesn't work.
109109
"queries.tests.Queries5Tests.test_ticket9848",
110-
# Variance is not implemented in mongo as an aggregation,
111-
# we should transform it into StdDev * 2.
112-
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_numerical_aggregates",
113110
# Sum returns 0 instead of None in mongodb.
114111
"aggregation.test_filter_argument.FilteredAggregateTests.test_plain_annotate",
115112
"aggregation.tests.AggregateTestCase.test_aggregation_default_passed_another_aggregate",
116113
"aggregation.tests.AggregateTestCase.test_annotation_expressions",
117114
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
118115
# Manage empty result when the flag elide_empty is False
119116
"aggregation.tests.AggregateTestCase.test_empty_result_optimization",
117+
# Order is not working well for aggregates.
118+
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
119+
"aggregation.tests.AggregateTestCase.test_combine_different_types",
120+
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
121+
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
122+
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
123+
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
124+
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
120125
}
121126
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
122127
_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)