Skip to content

Commit 3a00c70

Browse files
committed
fix QuerySet.alias() column selection
1 parent 15e97c5 commit 3a00c70

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

django_mongodb/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def get_columns(self):
154154
self.get_default_columns(select_mask) if self.query.default_cols else self.query.select
155155
)
156156
return tuple((column.target.column, column) for column in columns) + tuple(
157-
self.query.annotations.items()
157+
self.query.annotation_select.items()
158158
)
159159

160160
def _get_ordering(self):

django_mongodb/features.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
6060
"db_functions.comparison.test_coalesce.CoalesceTests.test_mixed_values",
6161
# $and must be an array
6262
"db_functions.tests.FunctionTests.test_function_as_filter",
63+
# pk__in=queryset doesn't work because subqueries aren't a thing in
64+
# MongoDB.
65+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_and_alias_filter_in_subquery",
6366
}
6467

6568
django_test_skips = {
@@ -163,9 +166,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
163166
"lookup.tests.LookupTests.test_exact_exists",
164167
"lookup.tests.LookupTests.test_nested_outerref_lhs",
165168
"lookup.tests.LookupQueryingTests.test_filter_exists_lhs",
166-
# QuerySet.alias() doesn't work.
167-
"annotations.tests.AliasTests.test_basic_alias_f_transform_annotation",
168-
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_and_alias_filter_in_subquery",
169+
# QuerySet.alias(greater=GreaterThan(F("year"), 1910)).filter(greater=True)
170+
# generates incorrect an incorrect query:
171+
# {'$expr': {'$eq': [{'year': {'$gt': 1910}}, True]}}}
169172
"lookup.tests.LookupQueryingTests.test_alias",
170173
# annotate() with combined expressions doesn't work:
171174
# 'WhereNode' object has no attribute 'field'

0 commit comments

Comments
 (0)