Opened 12 years ago

Closed 12 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

Description

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/query.py", line 525, in delete
    collector.collect(del_query)
  File "/home/akaariai/Programming/django/tests/django/db/models/deletion.py", line 195, in collect
    reverse_dependency=reverse_dependency)
  File "/home/akaariai/Programming/django/tests/django/db/models/deletion.py", 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 by Anssi Kääriäinen, 12 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

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

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