mirror of
https://github.com/django/django.git
synced 2025-10-29 16:46:11 +00:00
Fixed #19607 - prefetch_related crash
Thanks to av@rdf.ru and flarno11@yahoo.de for the report.
This commit is contained in:
@@ -1558,8 +1558,13 @@ def prefetch_related_objects(result_cache, related_lookups):
|
||||
good_objects = False
|
||||
break
|
||||
else:
|
||||
# We already did this list
|
||||
break
|
||||
# Since prefetching can re-use instances, it is possible to
|
||||
# have the same instance multiple times in obj_list. So we
|
||||
# can reach this branch either because we did all of
|
||||
# obj_list already, or because we did 'obj' earlier in this
|
||||
# iteration over obj_list. In the first case we could
|
||||
# shortcut and exit the loop, but not in the second.
|
||||
continue
|
||||
if not good_objects:
|
||||
break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user