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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user