#13309 closed (fixed)
Queryset.delete() only works if there are less than CHUNKSIZE models in the result.
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
It seems revision [12912] broke deleting a whole queryset when the queryset.count > CHUNK_SIZE. I should note I am using MySQL and haven't tried on any other backends.
Consider the following example:
for x in range(300):
track = Foo.objects.create(foo='bar')
Foo.objects.all().delete()
print Foo.objects.all().count()
The print displays 200 instead of 0. While stepping through the code (django/db/models/[Error: Query filter requires field and constraints separated by a "="])
for i, obj in izip(xrange(CHUNK_SIZE), del_query):
print i, obj.id
obj._collect_sub_objects(seen_objs)
Is printing out
0 1 1 2 2 3 ... 99 100 0 None 1 None ... 99 None
Change History (4)
comment:1 by , 16 years ago
| milestone: | → 1.2 |
|---|
comment:2 by , 16 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:3 by , 16 years ago
Note:
See TracTickets
for help on using tickets.
(In [12941]) Fixed #13309 -- Ensure that delete() deletes everything it should delete(). Thanks to craig.kimerer@… for the report.