Skip to content

Commit 1ead496

Browse files
committed
Update features skipped tests.
1 parent 74886c9 commit 1ead496

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",
@@ -106,14 +116,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
106116
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
107117
# Manage empty result when the flag elide_empty is False
108118
"aggregation.tests.AggregateTestCase.test_empty_result_optimization",
109-
# Order is not working well for aggregates.
110-
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
111-
"aggregation.tests.AggregateTestCase.test_combine_different_types",
112-
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
113-
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
114-
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
115-
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
116-
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
117119
}
118120
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
119121
_django_test_expected_failures_bitwise = {
@@ -254,44 +256,10 @@ def django_test_expected_failures(self):
254256
"db_functions.comparison.test_cast.CastTests.test_cast_to_integer_foreign_key",
255257
"model_fields.test_foreignkey.ForeignKeyTests.test_to_python",
256258
},
257-
# https://github.com/mongodb-labs/django-mongodb/issues/12
258-
"QuerySet.aggregate() not supported.": {
259-
"annotations.tests.AliasTests.test_alias_default_alias_expression",
260-
"annotations.tests.AliasTests.test_filter_alias_agg_with_double_f",
261-
"annotations.tests.NonAggregateAnnotationTestCase.test_aggregate_over_annotation",
262-
"annotations.tests.NonAggregateAnnotationTestCase.test_aggregate_over_full_expression_annotation",
263-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_aggregate_values_chaining",
264-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_in_f_grouped_by_annotation",
265-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
266-
"annotations.tests.NonAggregateAnnotationTestCase.test_filter_agg_with_double_f",
267-
"annotations.tests.NonAggregateAnnotationTestCase.test_values_with_pk_annotation",
268-
"expressions.test_queryset_values.ValuesExpressionsTests.test_chained_values_with_expression",
269-
"expressions.test_queryset_values.ValuesExpressionsTests.test_values_expression_group_by",
270-
"expressions.tests.BasicExpressionsTests.test_annotate_values_aggregate",
271-
"expressions_case.tests.CaseExpressionTests.test_aggregate",
272-
"expressions_case.tests.CaseExpressionTests.test_aggregate_with_expression_as_condition",
273-
"expressions_case.tests.CaseExpressionTests.test_aggregate_with_expression_as_value",
274-
"expressions_case.tests.CaseExpressionTests.test_aggregation_empty_cases",
275-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_condition",
276-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_predicate",
277-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_value",
278-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause",
279-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_condition",
280-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_predicate",
281-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_value",
282-
"expressions_case.tests.CaseExpressionTests.test_m2m_exclude",
283-
"expressions_case.tests.CaseExpressionTests.test_m2m_reuse",
284-
"lookup.test_decimalfield.DecimalFieldLookupTests",
285-
"lookup.tests.LookupQueryingTests.test_aggregate_combined_lookup",
286-
"from_db_value.tests.FromDBValueTest.test_aggregation",
287-
"timezones.tests.LegacyDatabaseTests.test_query_aggregation",
288-
"timezones.tests.LegacyDatabaseTests.test_query_annotation",
289-
"timezones.tests.NewDatabaseTests.test_query_aggregation",
290-
"timezones.tests.NewDatabaseTests.test_query_annotation",
291-
},
292259
"Exists is not supported on MongoDB.": {
293260
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregate_on_exists",
294261
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregate_ref_multiple_subquery_annotation",
262+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_aggregate_values_chaining",
295263
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_none_query",
296264
"aggregation.tests.AggregateTestCase.test_aggregation_exists_multivalued_outeref",
297265
"aggregation.tests.AggregateTestCase.test_group_by_exists_annotation",
@@ -332,6 +300,8 @@ def django_test_expected_failures(self):
332300
"queries.tests.Queries1Tests.test_nested_exclude",
333301
"queries.tests.Queries4Tests.test_join_reuse_order",
334302
"queries.tests.Queries4Tests.test_ticket24525",
303+
"queries.tests.Queries1Tests.test_ticket7096",
304+
"queries.tests.Queries1Tests.test_tickets_5324_6704",
335305
"queries.tests.Queries6Tests.test_tickets_8921_9188",
336306
"queries.tests.Queries6Tests.test_xor_subquery",
337307
"queries.tests.QuerySetBitwiseOperationTests.test_subquery_aliases",
@@ -349,10 +319,12 @@ def django_test_expected_failures(self):
349319
"aggregation.tests.AggregateTestCase.test_aggregation_subquery_annotation_values",
350320
"aggregation.tests.AggregateTestCase.test_aggregation_subquery_annotation_values_collision",
351321
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_filter_with_subquery",
322+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
352323
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_outerref_transform",
353324
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_queryset_annotation",
354325
"db_functions.datetime.test_extract_trunc.DateFunctionTests.test_extract_outerref",
355326
"db_functions.datetime.test_extract_trunc.DateFunctionTests.test_trunc_subquery_with_parameters",
327+
"expressions.tests.BasicExpressionsTests.test_aggregate_subquery_annotation"
356328
"expressions.tests.BasicExpressionsTests.test_annotation_with_nested_outerref",
357329
"expressions.tests.BasicExpressionsTests.test_annotation_with_outerref",
358330
"expressions.tests.BasicExpressionsTests.test_annotations_within_subquery",
@@ -383,6 +355,7 @@ def django_test_expected_failures(self):
383355
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_and_alias_filter_related_in_subquery",
384356
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_expression_annotation",
385357
"db_functions.comparison.test_coalesce.CoalesceTests.test_empty_queryset",
358+
"expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause",
386359
"expressions.tests.FTimeDeltaTests.test_date_subquery_subtraction",
387360
"expressions.tests.FTimeDeltaTests.test_datetime_subquery_subtraction",
388361
"expressions.tests.FTimeDeltaTests.test_time_subquery_subtraction",
@@ -416,30 +389,6 @@ def django_test_expected_failures(self):
416389
"queries.tests.WeirdQuerysetSlicingTests.test_empty_sliced_subquery_exclude",
417390
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_reused_subquery",
418391
},
419-
# Invalid $project :: caused by :: Unknown expression $count
420-
# https://github.com/mongodb-labs/django-mongodb/issues/79
421-
"Count() in QuerySet.annotate() crashes.": {
422-
"annotations.tests.AliasTests.test_alias_annotate_with_aggregation",
423-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_exists",
424-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_with_aggregation",
425-
"annotations.tests.NonAggregateAnnotationTestCase.test_combined_expression_annotation_with_aggregation",
426-
"annotations.tests.NonAggregateAnnotationTestCase.test_combined_f_expression_annotation_with_aggregation",
427-
"annotations.tests.NonAggregateAnnotationTestCase.test_full_expression_annotation_with_aggregation",
428-
"annotations.tests.NonAggregateAnnotationTestCase.test_grouping_by_q_expression_annotation",
429-
"annotations.tests.NonAggregateAnnotationTestCase.test_order_by_aggregate",
430-
"annotations.tests.NonAggregateAnnotationTestCase.test_q_expression_annotation_with_aggregation",
431-
"db_functions.comparison.test_cast.CastTests.test_cast_from_db_datetime_to_date_group_by",
432-
"defer_regress.tests.DeferRegressionTest.test_basic",
433-
"defer_regress.tests.DeferRegressionTest.test_defer_annotate_select_related",
434-
"defer_regress.tests.DeferRegressionTest.test_ticket_16409",
435-
"expressions.tests.BasicExpressionsTests.test_aggregate_subquery_annotation",
436-
"expressions.tests.FieldTransformTests.test_month_aggregation",
437-
"expressions_case.tests.CaseDocumentationExamples.test_conditional_aggregation_example",
438-
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_count",
439-
"ordering.tests.OrderingTests.test_default_ordering_does_not_affect_group_by",
440-
"queries.tests.Queries1Tests.test_ticket_20250",
441-
"queries.tests.ValuesQuerysetTests.test_named_values_list_expression_with_default_alias",
442-
},
443392
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB.": {
444393
"delete.tests.FastDeleteTests.test_fast_delete_aggregation",
445394
"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)