Skip to content

Commit 682c46a

Browse files
committed
Set expect failure to tests that have get ordering issue.
1 parent 4049efc commit 682c46a

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
@@ -330,7 +330,9 @@ def build_query(self, columns=None):
330330
query.project_fields = self.get_project_fields(columns, ordering=query.ordering)
331331
try:
332332
where = getattr(self, "where", self.query.where)
333-
query.mongo_query = {"$expr": where.as_mql(self, self.connection)}
333+
query.mongo_query = (
334+
{"$expr": where.as_mql(self, self.connection)} if where is not None else {}
335+
)
334336
except FullResultSet:
335337
query.mongo_query = {}
336338
return query

django_mongodb/features.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,21 @@ class DatabaseFeatures(BaseDatabaseFeatures):
127127
"queries.test_explain.ExplainUnsupportedTests.test_message",
128128
# filter() on related model + update() doesn't work.
129129
"queries.tests.Queries5Tests.test_ticket9848",
130-
# Variance is not implemented in mongo as an aggregation,
131-
# we should transform it into StdDev * 2.
132-
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_numerical_aggregates",
133130
# Sum returns 0 instead of None in mongodb.
134131
"aggregation.test_filter_argument.FilteredAggregateTests.test_plain_annotate",
135132
"aggregation.tests.AggregateTestCase.test_aggregation_default_passed_another_aggregate",
136133
"aggregation.tests.AggregateTestCase.test_annotation_expressions",
137134
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
138135
# Manage empty result when the flag elide_empty is False
139136
"aggregation.tests.AggregateTestCase.test_empty_result_optimization",
137+
# Order is not working well for aggregates.
138+
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
139+
"aggregation.tests.AggregateTestCase.test_combine_different_types",
140+
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
141+
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
142+
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
143+
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
144+
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
140145
}
141146
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
142147
_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)