Postgres supports using `UPDATE ... FROM`
([https://stackoverflow.com/questions/18797608/update-multiple-rows-in-
same-query-using-postgresql]) and we can possibly emulate this with MySQL
and `UNION ...`'s.
--
Ticket URL: <https://code.djangoproject.com/ticket/29771>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:1>
Comment (by Vineeth Sagar):
Is anyone working on this? Can I have a go at it?
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:2>
* owner: nobody => Tom Forbes
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:2>
* cc: Tom Forbes (added)
Comment:
I think the groundwork to this is quite difficult to lay. The current
`SQLUpdateCompiler` is not suitable for this, I think.
Also I believe we can mimic this on SQLLite:
{{{
WITH test(id) AS (SELECT 1 UNION ALL SELECT 2)
UPDATE demo
SET name=(select id from test where id=demo.id)
WHERE id IN (select id from test)
}}}
Whether or not this is faster is something I'm not sure of. I believe the
MySQL syntax will be faster, and there is no SQL standard way of doing
this (I believe?), so we are left with a number of pretty different
workarounds. I'm not sure how to structure this nicely.
I can maybe hack Postgres support into the SQLUpdateCompiler, but it's
really not nice. We have to create all the aliases ourselves, manage the
different column names, etc etc.
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:3>
* cc: Brillgen Developers (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:4>
* cc: Srinivas Reddy Thatiparthy (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:5>
* cc: Adam (Chainz) Johnson (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:6>
* cc: Shai Berger (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:7>
* owner: Tom Forbes => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:8>
* cc: Akash Kumar Sen (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:9>
* owner: (none) => Akash Kumar Sen
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:10>
* cc: John Speno (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29771#comment:11>