#36877: Order of update operations behaves differently on MySQL compared to
other
databases
--------------------------------------+------------------------------------
Reporter: Samir Shah | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 6.0
Severity: Normal | Resolution:
Keywords: mysql | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Simon Charette):
* component: Database layer (models, ORM) => Documentation
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization
Comment:
Thank you for your report Samir, I could swear I dropped a message here
already but I think we should won't fix or focus it as a documentation
admonition
Because `update(**fields)` maintains the user specified order I think we
must keep things as is to allow either `NEW` or `OLD` tuple values to be
targetted. Changing the default behaviour on MySQL seems clever but it
suffers from a few problems
1. It's backward incompatible, users might be relying on this MySQL'ism
with explicit `**fields` ordering just like they do with `order_by` (see
#31573)
2. Forcing a particular order is error prone as there could be inter-
dependency that only the user know about between the updated fields
3. It opens a can of worms for other interfaces that use `update` such as
`Model.save` which defauls to the order of definition of the model fields
For these reasons I think we're better off keeping things as they are as
they allow the user to have more control over the expressiveness of the
resulting `UPDATE` query which is a property the ORM maintained since
`dict` preserve insertion order (Python 3.7+ in 2018).
--
Ticket URL: <https://code.djangoproject.com/ticket/36877#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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019c000c7e4b-c6a47199-b72d-4c11-82a4-a3b6a9048cee-000000%40eu-central-1.amazonses.com.