#23646: query set sql update to change different values by different keys
-------------------------------------+-------------------------------------
     Reporter:  brillgen             |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |               Resolution:  wontfix
     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 freakboy3742):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 The link you've provided suggests that the ORM example you've provided
 would be interpreted as:
 {{{
 UPDATE books_book
 SET
  price = 10 where pk = 1,
  price = 25 where pk = 2
 }}}

 So... what in the ORM statement identifies which column is to be used in
 the `WHERE` clause, and which is to be updated? As currently expressed,
 it's ambiguous. You'd need to modify the statement to be something like:

 {{{
 Books.objects.all().update('pk', values={'pk': 1, 'price': 10}, {'pk': 2,
 'price': 25})
 }}}

 which nominates which values in the data are for the select.

 However, even with those changes, I'm not sure I see why doing this as a
 single statement version would be preferable to:

 {{{
 Book.objects.filter(pk=1).update(price=10)
 Book.objects.filter(pk=2).update(price=25)
 }}}

 AFAIK, it's no faster on the database side (although feel free to prove me
 wrong on that), and I don't find a "one liner API" especially expressive
 or clear for this feature.

 For that reason, I'm marking this wontfix. If you feel the idea is still
 worth pursuing, feel free to start a discussion on django-developers and
 make your case. (I know you started one on django-users, but in this case,
 you need the eyeballs from -dev).

--
Ticket URL: <https://code.djangoproject.com/ticket/23646#comment:2>
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.aa71bc6fab561e8b0252084fbab6bf75%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to