Skip to content

Commit

Permalink
Merge pull request #2677 from bagerard/improve_last_merged_fix
Browse files Browse the repository at this point in the history
Improve last merged fix
  • Loading branch information
bagerard committed Jul 17, 2022
2 parents 564f4bd + 6479b24 commit 5a325a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog
Development
===========
- (Fill this out as you fix issues and develop your features).
- Turning off dereferencing for the results of distinct query. #2663

Changes in 0.24.2
=================
Expand Down
9 changes: 5 additions & 4 deletions mongoengine/queryset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,11 +953,12 @@ def distinct(self, field):
field = self._fields_to_dbfields([field]).pop()
except LookUpError:
pass

raw_values = queryset._cursor.distinct(field)
if not self._auto_dereference:
return queryset._cursor.distinct(field)
distinct = self._dereference(
queryset._cursor.distinct(field), 1, name=field, instance=self._document
)
return raw_values

distinct = self._dereference(raw_values, 1, name=field, instance=self._document)

doc_field = self._document._fields.get(field.split(".", 1)[0])
instance = None
Expand Down

0 comments on commit 5a325a6

Please sign in to comment.