Adds back default primary key ordering.

pull/3940/head
Bertrand Bordage 2017-10-18 22:06:57 +01:00
rodzic d19934512d
commit 42c38a6af0
1 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -212,12 +212,12 @@ class PostgresSearchQuery(BaseSearchQuery):
queryset = queryset.annotate( queryset = queryset.annotate(
_rank_=SearchRank(F('_search_'), search_query, _rank_=SearchRank(F('_search_'), search_query,
weights=WEIGHTS_VALUES) weights=WEIGHTS_VALUES)
).order_by('-_rank_') ).order_by('-_rank_', '-pk')
elif not queryset.query.order_by:
# Adds a default ordering to avoid issue #3729.
queryset = queryset.order_by('-pk')
return queryset[start:stop] return queryset[start:stop]
def search_count(self, config):
return self.search(config, None, None).count()
class PostgresSearchResults(BaseSearchResults): class PostgresSearchResults(BaseSearchResults):
def get_config(self): def get_config(self):
@ -230,7 +230,7 @@ class PostgresSearchResults(BaseSearchResults):
self.start, self.stop)) self.start, self.stop))
def _do_count(self): def _do_count(self):
return self.query.search_count(self.get_config()) return self.query.search(self.get_config(), None, None).count()
class PostgresSearchRebuilder: class PostgresSearchRebuilder: