0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Fixes postgres_search when using annotate_score & order_by_relevance=False.

This commit is contained in:
Bertrand Bordage 2018-05-13 00:55:20 +02:00
parent 3c862676dd
commit d411fee905

View File

@ -282,7 +282,7 @@ class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
elif not queryset.query.order_by:
# Adds a default ordering to avoid issue #3729.
queryset = queryset.order_by('-pk')
rank_expression = F('pk').desc()
rank_expression = F('pk')
if score_field is not None:
queryset = queryset.annotate(**{score_field: rank_expression})
return queryset[start:stop]