Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#13309 closed (fixed)

Queryset.delete() only works if there are less than CHUNKSIZE models in the result.

Reported by: craig.kimerer@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 Changed 7 years ago by Alex Gaynor

milestone: 1.2

comment:2 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [12941]) Fixed #13309 -- Ensure that delete() deletes everything it should delete(). Thanks to craig.kimerer@… for the report.

comment:3 Changed 7 years ago by Russell Keith-Magee

(In [12955]) [1.1.X] Fixed #13309 -- Ensure that delete() deletes everything it should delete(). Thanks to craig.kimerer@… for the report

Backport of r12941 from trunk.

comment:4 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top