#5417: Add a way to update multiple records at once
-----------------------+----------------------------------------------------
Reporter: adrian | Owner: nobody
Status: new | Component: Database wrapper
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------+----------------------------------------------------
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:
{{{
#!python
# UPDATE place SET city='Chicago' WHERE city='chicago';
Place.objects.filter(city='chicago').update(city='Chicago')
# UPDATE contestant SET age=age+2 WHERE answer='1';
Contestant.objects.filter(answer='1').update(age=SqlClause('age+2'))
}}}
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.
--
Ticket URL: <http://code.djangoproject.com/ticket/5417>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---