Code

#19187 closed Bug (fixed)

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

Reported by: akaariai 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.

Attachments (0)

Change History (2)

comment:1 Changed 18 months ago by akaariai

  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

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

  • Resolution set to fixed
  • Status changed from new to closed

In 7de439f32d5da88f8a5717717a9e152441708a9f:

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.