Skip to content

Commit ad3c116

Browse files
committed
fix tests?
1 parent f33c42c commit ad3c116

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

django_mongodb/compiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,14 @@ def _get_ordering(self):
481481
else:
482482
# The expression must be added to extra_fields with an alias.
483483
field_name = f"__order{next(idx)}"
484-
extra_fields[field_name] = order.expression
484+
fields[field_name] = order.expression
485485
# If the expression is ordered by NULLS FIRST or NULLS LAST,
486486
# add a field for sorting that's 1 if null or 0 if not.
487487
if order.nulls_first or order.nulls_last:
488488
null_fieldname = f"__order{next(idx)}"
489489
condition = When(IsNull(order.expression, True), then=Value(1))
490490
extra_fields[null_fieldname] = Case(condition, default=Value(0))
491491
sort_ordering[null_fieldname] = DESCENDING if order.nulls_first else ASCENDING
492-
fields[field_name] = order.expression
493492
sort_ordering[field_name] = DESCENDING if order.descending else ASCENDING
494493
return tuple(fields.items()), sort_ordering, tuple(extra_fields.items())
495494

0 commit comments

Comments
 (0)