Skip to content

Commit 9ff6438

Browse files
committed
Avoid project field collision.
1 parent cbedd74 commit 9ff6438

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

django_mongodb/compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.db.models.expressions import Col, OrderBy, Value
66
from django.db.models.sql import compiler
77
from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE, MULTI, ORDER_DIR, SINGLE
8-
98
from django.utils.functional import cached_property
109

1110
from .base import Cursor
@@ -464,7 +463,8 @@ def get_project_fields(self, columns=None, ordering=None):
464463
fields[alias] = 1
465464

466465
for column, _ in ordering or []:
467-
if column not in fields:
466+
foreign_table = column.split(".", 1)[0] if "." in column else None
467+
if column not in fields and foreign_table not in fields:
468468
fields[column] = 1
469469

470470
return fields

0 commit comments

Comments
 (0)