diff --git a/django_mongodb/compiler.py b/django_mongodb/compiler.py index 1b8807a01..d01d9e946 100644 --- a/django_mongodb/compiler.py +++ b/django_mongodb/compiler.py @@ -550,7 +550,11 @@ def get_project_fields(self, columns=None, ordering=None, force_expression=False else expr.as_mql(self, self.connection) ) except EmptyResultSet: - fields[collection][name] = Value(False).as_mql(self, self.connection) + empty_result_set_value = getattr(expr, "empty_result_set_value", NotImplemented) + value = ( + False if empty_result_set_value is NotImplemented else empty_result_set_value + ) + fields[collection][name] = Value(value).as_mql(self, self.connection) except FullResultSet: fields[collection][name] = Value(True).as_mql(self, self.connection) # Annotations (stored in None) and the main collection's fields diff --git a/django_mongodb/features.py b/django_mongodb/features.py index 842e89c48..b17f3abe7 100644 --- a/django_mongodb/features.py +++ b/django_mongodb/features.py @@ -73,10 +73,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): "backends.tests.ThreadTests.test_pass_connection_between_threads", "backends.tests.ThreadTests.test_closing_non_shared_connections", "backends.tests.ThreadTests.test_default_connection_thread_local", - # Column default values aren't handled when a field raises - # EmptyResultSet: https://github.com/mongodb-labs/django-mongodb/issues/155 - "annotations.tests.NonAggregateAnnotationTestCase.test_empty_queryset_annotation", - "db_functions.comparison.test_coalesce.CoalesceTests.test_empty_queryset", # Union as subquery is not mapping the parent parameter and collections: # https://github.com/mongodb-labs/django-mongodb/issues/156 "queries.test_qs_combinators.QuerySetSetOperationTests.test_union_in_subquery_related_outerref",