Opened 11 years ago
Closed 11 years ago
#21205 closed Bug (duplicate)
related_objects() fails on SQLite when passing more than 999 objects
Reported by: | Andrei Picus | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | sqlite delete related 999 |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using SQLite, trying to delete objects that have more than 999 related objects will fail with a 'too many SQL variables' error. This is due to the related_objects() method getting all the related objects in one query.
I've written a patch to fetch the related objects in batches using the bulk_batch_size database ops. You can check it here:
https://github.com/django/django/pull/1699
Also added a new test to check for this new behavior.
All comments are welcome.
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Seems like it. But, looking at the proposed patch, I see that it doesn't use the max_batch_size database ops.
Also, the splitting occurs at the collect() level, while I propose that it happens in related_objects(), as that's where the problem lies.
Feel free to discuss both patches.
I think this should be fixed as soon as possible since it could break a lot of people's code, especially when trying to truncate tables via objects.all().delete().
comment:3 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Let's keep the discussion in a single place; I'm marking this ticket as a duplicate of #16426.
Isn't this a duplicate of #16426?