#23646: query set sql update to change different values by different keys
-------------------------------------+-------------------------------------
     Reporter:  brillgen             |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by brillgen):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Old description:

> Database backends like Postgresql support doing multiple value update for
> the same field in different rows using a single update query. Please see
> this sample below:
>
> http://stackoverflow.com/questions/18797608/update-multiple-rows-in-same-
> query-using-postgresql
>
> However, such an interface is not exposed via the Django ORM. Would this
> be accepted as a patch? if so, would a list dictionary with the various
> fields:values to be updated be a good way to provide the input to ORM

New description:

 Database backends like Postgresql support doing multiple value update for
 the same field in different rows using a single update query. Please see
 this sample below:

 http://stackoverflow.com/questions/18797608/update-multiple-rows-in-same-
 query-using-postgresql

 Example:
 Currently:
 {{{
 Books.objects.all().update(price=10)
 }}}

 Proposed (syntax can vary):
 {{{
 Books.objects.all().update({'pk': 1, 'price': 10}, {'pk': 2, 'price':
 25}])
 }}}

 Idea is to do it in sql for performance reasons but still use the ORM and
 not use a raw database connection.

 However, such an interface is not exposed via the Django ORM. Would this
 be accepted as a patch? if so, would a list dictionary with the various
 fields:values to be updated be a good way to provide the input to ORM

--

--
Ticket URL: <https://code.djangoproject.com/ticket/23646#comment:1>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.8c16a6aa108fc635a27ed8628f9ca53e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to