Opened 11 years ago

Closed 11 years ago

#5417 closed (duplicate)

Add a way to update multiple records at once

Reported by: Adrian Holovaty Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: feature_request, qs-rf
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


The Django ORM currently doesn't allow for the update of multiple records in a single statement. We can add this feature in a pretty clean and consistent way by adding a QuerySet.update() method:

# UPDATE place SET city='Chicago' WHERE city='chicago';

# UPDATE contestant SET age=age+2 WHERE answer='1';

The second example introduces SqlClause, which would be a way of specifying clauses instead of hard-coded values. We could potentially begin using this SqlClause in other places, too.

Attachments (1)

mult_update_partial.diff (1.0 KB) - added by deepak <deep.thukral@…> 11 years ago.
need testing doing part1

Download all attachments as: .zip

Change History (5)

comment:1 Changed 11 years ago by Philippe Raoult

Keywords: feature_request added

comment:2 Changed 11 years ago by Simon G. <dev@…>

Keywords: qs-rf added
Triage Stage: UnreviewedAccepted

Changed 11 years ago by deepak <deep.thukral@…>

Attachment: mult_update_partial.diff added

need testing doing part1

comment:3 Changed 11 years ago by deepak <deep.thukral@…>

Has patch: set
Needs tests: set

Sorry, I was working on it before qs-rf tag, so I just added where i was till then. Its partial patch(covers example 1) and needs testing.

comment:4 Changed 11 years ago by James Bennett

Resolution: duplicate
Status: newclosed

Duplicate of #4260.

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