Skip to content

Conversation

@danifus
Copy link
Contributor

@danifus danifus commented Apr 18, 2021

The previous limit was a max of 1000 query parameters. This is changed
to a max of 1000 rows (the max number of rows allowed for inserting in a
single statement by mssql) or however many rows can be inserted while
keeping the number of query parameters below 2050 per insert statement
(mssql reports a max allowed of 2100 parameters but a few parameters are
reserved for executing the query).

@absci
Copy link
Contributor

absci commented Apr 19, 2021

Hi, thanks for your contribution, there's one unit test that failed. Is it possible for you to fix it?

ERROR: test_empty_model (bulk_create.tests.BulkCreateTests)

Traceback (most recent call last):
File "/home/vsts/work/1/s/django/tests/bulk_create/tests.py", line 205, in test_empty_model
NoFields.objects.bulk_create([NoFields() for i in range(2)])
File "/home/vsts/work/1/s/.tox/py37-django30/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/vsts/work/1/s/.tox/py37-django30/lib/python3.7/site-packages/django/db/models/query.py", line 493, in bulk_create
objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts,
File "/home/vsts/work/1/s/.tox/py37-django30/lib/python3.7/site-packages/django/db/models/query.py", line 1215, in _batched_insert
batch_size = (batch_size or max(ops.bulk_batch_size(fields, objs), 1))
File "/home/vsts/work/1/s/.tox/py37-django30/lib/python3.7/site-packages/mssql/operations.py", line 59, in bulk_batch_size
return min(1000, max_query_params // fields_len)
ZeroDivisionError: integer division or modulo by zero

@ghost
Copy link

ghost commented Apr 19, 2021

CLA assistant check
All CLA requirements met.

The previous limit was a max of 1000 query parameters. This is changed
to a max of 1000 rows (the max number of rows allowed for inserting in a
single statement by mssql) or however many rows can be inserted while
keeping the number of query parameters below 2050 per insert statement
(mssql reports a max allowed of 2100 parameters but a few parameters are
reserved for executing the query).
@danifus
Copy link
Contributor Author

danifus commented Apr 20, 2021

Hi, I got distracted before the CI finished :p

I've pushed a fix which should address that issue.

@absci absci merged commit d1914cc into microsoft:dev May 7, 2021
@absci
Copy link
Contributor

absci commented May 7, 2021

Thanks for this contribution, it has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants