Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd04a584

Browse files
committed
Fix RelatedSearchQueryset.load_all() truncating results
Fixes#2011
1 parent7d139b4 commitd04a584

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

‎haystack/query.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ def post_process_results(self, results):
194194
# No objects were returned -- possible due to SQS nesting such as
195195
# XYZ.objects.filter(id__gt=10) where the amount ignored are
196196
# exactly equal to the ITERATOR_LOAD_PER_QUERY
197-
delself._result_cache[:len(results)]
198-
self._ignored_result_count+=len(results)
199-
break
197+
delself._result_cache[:1]
198+
self._ignored_result_count+=1
199+
continue
200200

201201
to_cache.append(result)
202202

‎test_haystack/solr_tests/test_solr_backend.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,21 @@ def test_related_load_all_queryset(self):
12201220
self.assertEqual([obj.object.idforobjinsqs],list(range(11,24)))
12211221
self.assertEqual([obj.object.idforobjinsqs[10:20]], [21,22,23])
12221222

1223+
deftest_related_load_all_with_empty_model_results(self):
1224+
another_index=SolrAnotherMockModelSearchIndex()
1225+
another_index.update("solr")
1226+
self.ui.build(indexes=[self.smmi,another_index])
1227+
1228+
sqs=self.rsqs.order_by("id")
1229+
assertlen(list(sqs))==25
1230+
sqs=sqs.all().load_all_queryset(
1231+
AnotherMockModel,AnotherMockModel.objects.none()
1232+
)
1233+
sqs=sqs.load_all()
1234+
# two AnotherMockModel objects are skipped, so only 23 results now
1235+
# (but those results are still present and weren't skipped)
1236+
assertlen(list(sqs))==23
1237+
12231238
deftest_related_iter(self):
12241239
reset_search_queries()
12251240
self.assertEqual(len(connections["solr"].queries),0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp