1
0
mirror of https://github.com/django/django.git synced 2025-10-30 00:56:09 +00:00

Fixed #36416 -- Made QuerySet.in_bulk() account for composite pks in id_list.

This commit is contained in:
Jacob Walls
2025-05-24 14:03:07 -04:00
committed by Sarah Boyce
parent 953095d1e6
commit 26313bc219
3 changed files with 23 additions and 1 deletions

View File

@@ -1180,7 +1180,9 @@ class QuerySet(AltersData):
if not id_list:
return {}
filter_key = "{}__in".format(field_name)
batch_size = connections[self.db].features.max_query_params
max_params = connections[self.db].features.max_query_params or 0
num_fields = len(opts.pk_fields) if field_name == "pk" else 1
batch_size = max_params // num_fields
id_list = tuple(id_list)
# If the database has a limit on the number of query parameters
# (e.g. SQLite), retrieve objects in batches if necessary.