Skip to content

Commit ce9607d

Browse files
committed
Update features skipped tests.
1 parent ff0894d commit ce9607d

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",
@@ -109,14 +119,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
109119
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
110120
# Manage empty result when the flag elide_empty is False
111121
"aggregation.tests.AggregateTestCase.test_empty_result_optimization",
112-
# Order is not working well for aggregates.
113-
"aggregation.tests.AggregateTestCase.test_annotate_values_list",
114-
"aggregation.tests.AggregateTestCase.test_combine_different_types",
115-
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
116-
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
117-
"aggregation.tests.AggregateTestCase.test_values_annotation_with_expression",
118-
"aggregation.tests.AggregateTestCase.test_annotate_ordering",
119-
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
120122
}
121123
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
122124
_django_test_expected_failures_bitwise = {
@@ -257,44 +259,10 @@ def django_test_expected_failures(self):
257259
"db_functions.comparison.test_cast.CastTests.test_cast_to_integer_foreign_key",
258260
"model_fields.test_foreignkey.ForeignKeyTests.test_to_python",
259261
},
260-
# https://github.com/mongodb-labs/django-mongodb/issues/12
261-
"QuerySet.aggregate() not supported.": {
262-
"annotations.tests.AliasTests.test_alias_default_alias_expression",
263-
"annotations.tests.AliasTests.test_filter_alias_agg_with_double_f",
264-
"annotations.tests.NonAggregateAnnotationTestCase.test_aggregate_over_annotation",
265-
"annotations.tests.NonAggregateAnnotationTestCase.test_aggregate_over_full_expression_annotation",
266-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_aggregate_values_chaining",
267-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_in_f_grouped_by_annotation",
268-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
269-
"annotations.tests.NonAggregateAnnotationTestCase.test_filter_agg_with_double_f",
270-
"annotations.tests.NonAggregateAnnotationTestCase.test_values_with_pk_annotation",
271-
"expressions.test_queryset_values.ValuesExpressionsTests.test_chained_values_with_expression",
272-
"expressions.test_queryset_values.ValuesExpressionsTests.test_values_expression_group_by",
273-
"expressions.tests.BasicExpressionsTests.test_annotate_values_aggregate",
274-
"expressions_case.tests.CaseExpressionTests.test_aggregate",
275-
"expressions_case.tests.CaseExpressionTests.test_aggregate_with_expression_as_condition",
276-
"expressions_case.tests.CaseExpressionTests.test_aggregate_with_expression_as_value",
277-
"expressions_case.tests.CaseExpressionTests.test_aggregation_empty_cases",
278-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_condition",
279-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_predicate",
280-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_aggregation_in_value",
281-
"expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause",
282-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_condition",
283-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_predicate",
284-
"expressions_case.tests.CaseExpressionTests.test_filter_with_aggregation_in_value",
285-
"expressions_case.tests.CaseExpressionTests.test_m2m_exclude",
286-
"expressions_case.tests.CaseExpressionTests.test_m2m_reuse",
287-
"lookup.test_decimalfield.DecimalFieldLookupTests",
288-
"lookup.tests.LookupQueryingTests.test_aggregate_combined_lookup",
289-
"from_db_value.tests.FromDBValueTest.test_aggregation",
290-
"timezones.tests.LegacyDatabaseTests.test_query_aggregation",
291-
"timezones.tests.LegacyDatabaseTests.test_query_annotation",
292-
"timezones.tests.NewDatabaseTests.test_query_aggregation",
293-
"timezones.tests.NewDatabaseTests.test_query_annotation",
294-
},
295262
"Exists is not supported on MongoDB.": {
296263
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregate_on_exists",
297264
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregate_ref_multiple_subquery_annotation",
265+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_aggregate_values_chaining",
298266
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_exists_none_query",
299267
"aggregation.tests.AggregateTestCase.test_aggregation_exists_multivalued_outeref",
300268
"aggregation.tests.AggregateTestCase.test_group_by_exists_annotation",
@@ -335,6 +303,8 @@ def django_test_expected_failures(self):
335303
"queries.tests.Queries1Tests.test_nested_exclude",
336304
"queries.tests.Queries4Tests.test_join_reuse_order",
337305
"queries.tests.Queries4Tests.test_ticket24525",
306+
"queries.tests.Queries1Tests.test_ticket7096",
307+
"queries.tests.Queries1Tests.test_tickets_5324_6704",
338308
"queries.tests.Queries6Tests.test_tickets_8921_9188",
339309
"queries.tests.Queries6Tests.test_xor_subquery",
340310
"queries.tests.QuerySetBitwiseOperationTests.test_subquery_aliases",
@@ -352,10 +322,12 @@ def django_test_expected_failures(self):
352322
"aggregation.tests.AggregateTestCase.test_aggregation_subquery_annotation_values",
353323
"aggregation.tests.AggregateTestCase.test_aggregation_subquery_annotation_values_collision",
354324
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_filter_with_subquery",
325+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
355326
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_outerref_transform",
356327
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_queryset_annotation",
357328
"db_functions.datetime.test_extract_trunc.DateFunctionTests.test_extract_outerref",
358329
"db_functions.datetime.test_extract_trunc.DateFunctionTests.test_trunc_subquery_with_parameters",
330+
"expressions.tests.BasicExpressionsTests.test_aggregate_subquery_annotation"
359331
"expressions.tests.BasicExpressionsTests.test_annotation_with_nested_outerref",
360332
"expressions.tests.BasicExpressionsTests.test_annotation_with_outerref",
361333
"expressions.tests.BasicExpressionsTests.test_annotations_within_subquery",
@@ -386,6 +358,7 @@ def django_test_expected_failures(self):
386358
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_and_alias_filter_related_in_subquery",
387359
"annotations.tests.NonAggregateAnnotationTestCase.test_empty_expression_annotation",
388360
"db_functions.comparison.test_coalesce.CoalesceTests.test_empty_queryset",
361+
"expressions_case.tests.CaseExpressionTests.test_annotate_with_in_clause",
389362
"expressions.tests.FTimeDeltaTests.test_date_subquery_subtraction",
390363
"expressions.tests.FTimeDeltaTests.test_datetime_subquery_subtraction",
391364
"expressions.tests.FTimeDeltaTests.test_time_subquery_subtraction",
@@ -419,30 +392,6 @@ def django_test_expected_failures(self):
419392
"queries.tests.WeirdQuerysetSlicingTests.test_empty_sliced_subquery_exclude",
420393
"aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_reused_subquery",
421394
},
422-
# Invalid $project :: caused by :: Unknown expression $count
423-
# https://github.com/mongodb-labs/django-mongodb/issues/79
424-
"Count() in QuerySet.annotate() crashes.": {
425-
"annotations.tests.AliasTests.test_alias_annotate_with_aggregation",
426-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_exists",
427-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotate_with_aggregation",
428-
"annotations.tests.NonAggregateAnnotationTestCase.test_combined_expression_annotation_with_aggregation",
429-
"annotations.tests.NonAggregateAnnotationTestCase.test_combined_f_expression_annotation_with_aggregation",
430-
"annotations.tests.NonAggregateAnnotationTestCase.test_full_expression_annotation_with_aggregation",
431-
"annotations.tests.NonAggregateAnnotationTestCase.test_grouping_by_q_expression_annotation",
432-
"annotations.tests.NonAggregateAnnotationTestCase.test_order_by_aggregate",
433-
"annotations.tests.NonAggregateAnnotationTestCase.test_q_expression_annotation_with_aggregation",
434-
"db_functions.comparison.test_cast.CastTests.test_cast_from_db_datetime_to_date_group_by",
435-
"defer_regress.tests.DeferRegressionTest.test_basic",
436-
"defer_regress.tests.DeferRegressionTest.test_defer_annotate_select_related",
437-
"defer_regress.tests.DeferRegressionTest.test_ticket_16409",
438-
"expressions.tests.BasicExpressionsTests.test_aggregate_subquery_annotation",
439-
"expressions.tests.FieldTransformTests.test_month_aggregation",
440-
"expressions_case.tests.CaseDocumentationExamples.test_conditional_aggregation_example",
441-
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_count",
442-
"ordering.tests.OrderingTests.test_default_ordering_does_not_affect_group_by",
443-
"queries.tests.Queries1Tests.test_ticket_20250",
444-
"queries.tests.ValuesQuerysetTests.test_named_values_list_expression_with_default_alias",
445-
},
446395
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB.": {
447396
"delete.tests.FastDeleteTests.test_fast_delete_aggregation",
448397
"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)