#30827 closed Bug (fixed)
bulk_create batch_size param overrides the compatible batch size calculation
| Reported by: | Ahmet Kucuk | Owned by: | Ahmet Kucuk |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Georgi Yanchev | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
At this line: https://github.com/django/django/blob/stable/2.2.x/django/db/models/query.py#L1197
batch_size param overrides compatible batch size calculation. This looks like a bug as bulk_update properly picks the minimum of two:
https://github.com/django/django/blob/stable/2.2.x/django/db/models/query.py#L504
I suggest using similar
batch_size = min(batch_size, max_batch_size) if batch_size else max_batch_size
logic in bulk_create as well. I am happy to open a PR for it.
Attachments (1)
Change History (10)
comment:1 by , 6 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 6 years ago
| Cc: | added |
|---|
comment:3 by , 6 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
comment:4 by , 6 years ago
| Component: | Uncategorized → Database layer (models, ORM) |
|---|
comment:5 by , 6 years ago
| Needs tests: | unset |
|---|
Hi!
I added a couple of tests to the patch. Since this is the first time I'm contributing to django, I'd love to hear any feedback or advice.
Thanks.
comment:7 by , 6 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Accepted → Ready for checkin |
| Version: | 2.2 → master |
I guess testing it will be harder than the fix!