Skip to content

Commit 82a65d3

Browse files
WaVEVtimgraham
authored andcommitted
Update features skipped tests.
1 parent ff97544 commit 82a65d3

File tree

3 files changed

+28
-69
lines changed

3 files changed

+28
-69
lines changed

django_mongodb/compiler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ def _get_group_id_expressions(self):
119119
ids = {}
120120
for col in group_expressions:
121121
alias, replacement = self._get_group_alias_column(col, annotation_group_idx)
122-
ids[alias] = col.as_mql(self, self.connection)
122+
try:
123+
ids[alias] = col.as_mql(self, self.connection)
124+
except EmptyResultSet:
125+
ids[alias] = Value(False).as_mql(self, self.connection)
126+
except FullResultSet:
127+
ids[alias] = Value(True).as_mql(self, self.connection)
123128
if replacement is not None:
124129
replacements[col] = replacement
125130

django_mongodb/features.py

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ class DatabaseFeatures(BaseDatabaseFeatures):
3434
"basic.tests.SelectOnSaveTests.test_select_on_save_lying_update",
3535
# Order by constant not supported:
3636
# AttributeError: 'Field' object has no attribute 'model'
37+
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
38+
"aggregation.tests.AggregateTestCase.test_combine_different_types",
39+
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
40+
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
41+
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
42+
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
43+
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
44+
"annotations.tests.NonAggregateAnnotationTestCase.test_order_by_aggregate",
45+
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_count",
46+
"ordering.tests.OrderingTests.test_default_ordering_does_not_affect_group_by",
3747
"ordering.tests.OrderingTests.test_order_by_constant_value",
3848
"expressions.tests.NegatedExpressionTests.test_filter",
3949
"expressions_case.tests.CaseExpressionTests.test_order_by_conditional_implicit",
@@ -103,14 +113,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
103113
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
104114
# Manage empty result when the flag elide_empty is False
105115
"aggregation.tests.AggregateTestCase.test_empty_result_optimization",
106-
# Order is not working well for aggregates.
107-
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
108-
"aggregation.tests.AggregateTestCase.test_combine_different_types",
109-
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
110-
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
111-
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
112-
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
113-
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
114116
}
115117
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
116118
_django_test_expected_failures_bitwise = {
@@ -251,44 +253,10 @@ def django_test_expected_failures(self):
251253
"db_functions.comparison.test_cast.CastTests.test_cast_to_integer_foreign_key",
252254
"model_fields.test_foreignkey.ForeignKeyTests.test_to_python",
253255
},
254-
# https://github.com/mongodb-labs/django-mongodb/issues/12
255-
"QuerySet.aggregate() not supported.": {
256-
"annotations.tests.AliasTests.test_alias_default_alias_expression",
257-
"annotations.tests.AliasTests.test_filter_alias_agg_with_double_f",
258-
"annotations.tests.NonAggregateAnnotationTestCase.test_aggregate_over_annotation",
259-
"annotations.tests.NonAggregateAnnotationTestCase.test_aggregate_over_full_expression_annotation",
260-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_aggregate_values_chaining",
261-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_in_f_grouped_by_annotation",
262-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
263-
"annotations.tests.NonAggregateAnnotationTestCase.test_filter_agg_with_double_f",
264-
"annotations.tests.NonAggregateAnnotationTestCase.test_values_with_pk_annotation",
265-
"expressions.test_queryset_values.ValuesExpressionsTests.test_chained_values_with_expression",
266-
"expressions.test_queryset_values.ValuesExpressionsTests.test_values_expression_group_by",
267-
"expressions.tests.BasicExpressionsTests.test_annotate_values_aggregate",
268-
"expressions_case.tests.CaseExpressionTests.test_aggregate",
269-
"expressions_case.tests.CaseExpressionTests.test_aggregate_with_expression_as_condition",
270-
"expressions_case.tests.CaseExpressionTests.test_aggregate_with_expression_as_value",
271-
"expressions_case.tests.CaseExpressionTests.test_aggregation_empty_cases",
272-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_condition",
273-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_predicate",
274-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_value",
275-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause",
276-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_condition",
277-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_predicate",
278-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_value",
279-
"expressions_case.tests.CaseExpressionTests.test_m2m_exclude",
280-
"expressions_case.tests.CaseExpressionTests.test_m2m_reuse",
281-
"lookup.test_decimalfield.DecimalFieldLookupTests",
282-
"lookup.tests.LookupQueryingTests.test_aggregate_combined_lookup",
283-
"from_db_value.tests.FromDBValueTest.test_aggregation",
284-
"timezones.tests.LegacyDatabaseTests.test_query_aggregation",
285-
"timezones.tests.LegacyDatabaseTests.test_query_annotation",
286-
"timezones.tests.NewDatabaseTests.test_query_aggregation",
287-
"timezones.tests.NewDatabaseTests.test_query_annotation",
288-
},
289256
"Exists is not supported on MongoDB.": {
290257
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregate_on_exists",
291258
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregate_ref_multiple_subquery_annotation",
259+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_aggregate_values_chaining",
292260
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_none_query",
293261
"aggregation.tests.AggregateTestCase.test_aggregation_exists_multivalued_outeref",
294262
"aggregation.tests.AggregateTestCase.test_group_by_exists_annotation",
@@ -329,6 +297,8 @@ def django_test_expected_failures(self):
329297
"queries.tests.Queries1Tests.test_nested_exclude",
330298
"queries.tests.Queries4Tests.test_join_reuse_order",
331299
"queries.tests.Queries4Tests.test_ticket24525",
300+
"queries.tests.Queries1Tests.test_ticket7096",
301+
"queries.tests.Queries1Tests.test_tickets_5324_6704",
332302
"queries.tests.Queries6Tests.test_tickets_8921_9188",
333303
"queries.tests.Queries6Tests.test_xor_subquery",
334304
"queries.tests.QuerySetBitwiseOperationTests.test_subquery_aliases",
@@ -346,10 +316,12 @@ def django_test_expected_failures(self):
346316
"aggregation.tests.AggregateTestCase.test_aggregation_subquery_annotation_values",
347317
"aggregation.tests.AggregateTestCase.test_aggregation_subquery_annotation_values_collision",
348318
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_filter_with_subquery",
319+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
349320
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_outerref_transform",
350321
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_queryset_annotation",
351322
"db_functions.datetime.test_extract_trunc.DateFunctionTests.test_extract_outerref",
352323
"db_functions.datetime.test_extract_trunc.DateFunctionTests.test_trunc_subquery_with_parameters",
324+
"expressions.tests.BasicExpressionsTests.test_aggregate_subquery_annotation"
353325
"expressions.tests.BasicExpressionsTests.test_annotation_with_nested_outerref",
354326
"expressions.tests.BasicExpressionsTests.test_annotation_with_outerref",
355327
"expressions.tests.BasicExpressionsTests.test_annotations_within_subquery",
@@ -380,6 +352,7 @@ def django_test_expected_failures(self):
380352
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_and_alias_filter_related_in_subquery",
381353
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_expression_annotation",
382354
"db_functions.comparison.test_coalesce.CoalesceTests.test_empty_queryset",
355+
"expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause",
383356
"expressions.tests.FTimeDeltaTests.test_date_subquery_subtraction",
384357
"expressions.tests.FTimeDeltaTests.test_datetime_subquery_subtraction",
385358
"expressions.tests.FTimeDeltaTests.test_time_subquery_subtraction",
@@ -413,30 +386,6 @@ def django_test_expected_failures(self):
413386
"queries.tests.WeirdQuerysetSlicingTests.test_empty_sliced_subquery_exclude",
414387
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_reused_subquery",
415388
},
416-
# Invalid $project :: caused by :: Unknown expression $count
417-
# https://github.com/mongodb-labs/django-mongodb/issues/79
418-
"Count() in QuerySet.annotate() crashes.": {
419-
"annotations.tests.AliasTests.test_alias_annotate_with_aggregation",
420-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_exists",
421-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_with_aggregation",
422-
"annotations.tests.NonAggregateAnnotationTestCase.test_combined_expression_annotation_with_aggregation",
423-
"annotations.tests.NonAggregateAnnotationTestCase.test_combined_f_expression_annotation_with_aggregation",
424-
"annotations.tests.NonAggregateAnnotationTestCase.test_full_expression_annotation_with_aggregation",
425-
"annotations.tests.NonAggregateAnnotationTestCase.test_grouping_by_q_expression_annotation",
426-
"annotations.tests.NonAggregateAnnotationTestCase.test_order_by_aggregate",
427-
"annotations.tests.NonAggregateAnnotationTestCase.test_q_expression_annotation_with_aggregation",
428-
"db_functions.comparison.test_cast.CastTests.test_cast_from_db_datetime_to_date_group_by",
429-
"defer_regress.tests.DeferRegressionTest.test_basic",
430-
"defer_regress.tests.DeferRegressionTest.test_defer_annotate_select_related",
431-
"defer_regress.tests.DeferRegressionTest.test_ticket_16409",
432-
"expressions.tests.BasicExpressionsTests.test_aggregate_subquery_annotation",
433-
"expressions.tests.FieldTransformTests.test_month_aggregation",
434-
"expressions_case.tests.CaseDocumentationExamples.test_conditional_aggregation_example",
435-
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_count",
436-
"ordering.tests.OrderingTests.test_default_ordering_does_not_affect_group_by",
437-
"queries.tests.Queries1Tests.test_ticket_20250",
438-
"queries.tests.ValuesQuerysetTests.test_named_values_list_expression_with_default_alias",
439-
},
440389
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB.": {
441390
"delete.tests.FastDeleteTests.test_fast_delete_aggregation",
442391
"delete.tests.FastDeleteTests.test_fast_delete_empty_no_update_can_self_select",

django_mongodb/operations.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ def convert_durationfield_value(self, value, expression, connection):
129129
return value
130130

131131
def convert_floatfield_value(self, value, expression, connection):
132-
return None if value is None else float(value)
132+
if value is None:
133+
return value
134+
if isinstance(value, Decimal128):
135+
return float(value.to_decimal())
136+
137+
return float(value)
133138

134139
def convert_integerfield_value(self, value, expression, connection):
135140
return None if value is None else int(value)

0 commit comments

Comments
 (0)