Opened 15 years ago

Closed 15 years ago

Last modified 13 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: 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 Alex Gaynor, 15 years ago

milestone: 1.2

comment:2 by Russell Keith-Magee, 15 years ago

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 by Russell Keith-Magee, 15 years ago

(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 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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