Skip to content

Commit 0c483eb

Browse files
committed
Fix overwriting project stage.
1 parent 88eafb3 commit 0c483eb

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

django_mongodb/compiler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,12 @@ def build_query(self, columns=None):
368368
)
369369
if not query.aggregation_pipeline:
370370
query.aggregation_pipeline = []
371-
query.aggregation_pipeline.append({"$group": {"_id": distinct_fields}})
372-
query.project_fields = {key: f"$_id.{key}" for key in distinct_fields}
371+
query.aggregation_pipeline.extend(
372+
[
373+
{"$group": {"_id": distinct_fields}},
374+
{"$project": {key: f"$_id.{key}" for key in distinct_fields}},
375+
]
376+
)
373377
else:
374378
# Otherwise, project fields without grouping.
375379
query.project_fields = self.get_project_fields(columns, ordering_fields)

django_mongodb/features.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
8888
"queries.tests.ValuesSubqueryTests.test_values_in_subquery",
8989
# Wrong results for distinct() queries.
9090
"admin_filters.tests.ListFiltersTests.test_emptylistfieldfilter_genericrelation",
91-
"admin_filters.tests.ListFiltersTests.test_facets_always",
92-
"admin_filters.tests.ListFiltersTests.test_facets_disallowed",
9391
"admin_filters.tests.ListFiltersTests.test_facets_filter",
94-
"admin_filters.tests.ListFiltersTests.test_facets_no_filter",
95-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_foreignkey",
96-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_foreignkey_default_ordering",
97-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_foreignkey_ordering",
98-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_foreignkey_reverse_relationships",
99-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_manytomany",
100-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_manytomany_reverse_relationships",
101-
"admin_filters.tests.ListFiltersTests.test_relatedonlyfieldlistfilter_underscorelookup_foreignkey",
10292
}
10393
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
10494
_django_test_expected_failures_bitwise = {

0 commit comments

Comments
 (0)