Opened 7 years ago

Closed 7 years ago

#19187 closed Bug (fixed)

qs.values().delete() doesn't work consistently

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If you do SomeModel.objects.values().delete() you will get a stack trace like this one:

  File "/home/akaariai/Programming/django/tests/django/db/models/", line 525, in delete
  File "/home/akaariai/Programming/django/tests/django/db/models/", line 195, in collect
  File "/home/akaariai/Programming/django/tests/django/db/models/", line 105, in add
    if obj not in instances:
  TypeError: unhashable type: 'dict'

However if the "fast-path" deletion route is taken, then the deletion will work.

I think we should make values().delete() and values_list().delete() throw an error explicitly. We might later on want to make values().delete() work, or have special meaning for such queries (see #9519 for example). But for now making sure that this errors consistently seems like a good idea.

Change History (2)

comment:1 Changed 7 years ago by Anssi Kääriäinen

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:2 Changed 7 years ago by Anssi Kääriäinen <akaariai@…>

Resolution: fixed
Status: newclosed

In 7de439f32d5da88f8a5717717a9e152441708a9f:

Fixed #19187 -- Raise consistent error from qs.values().delete()

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