Skip to content

Commit e51fefd

Browse files
committed
Using 1 projection when the column target and the column name are the same.
1 parent 9aefa73 commit e51fefd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

django_mongodb/compiler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ def get_project_fields(self, columns=None, ordering=None):
432432
for name, expr in columns or []:
433433
collection = expr.alias if isinstance(expr, Col) else None
434434
try:
435-
fields[collection][name] = expr.as_mql(self, self.connection)
435+
fields[collection][name] = (
436+
1
437+
if isinstance(expr, Col) and name == expr.target.column
438+
else expr.as_mql(self, self.connection)
439+
)
436440
except EmptyResultSet:
437441
fields[collection][name] = Value(False).as_mql(self, self.connection)
438442
except FullResultSet:

0 commit comments

Comments
 (0)