#34179: Django F expression not working as expected on MariaDB 10.5.13
-------------------------------------+-------------------------------------
Reporter: Gerben | Owner: nobody
Morsink |
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords: mysql, mariadb
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
My hosting updated the server from MySQL 5.7 to MariaDB 10.5.13. Although
all data was preserved correctly, I found out the ordering of some Model
instances stopped working.
After spending multiple days on the issue I have found that the issue
comes from the fix that is created here:
https://code.djangoproject.com/ticket/31573
Somehow with (this version of?) MariaDB when you add the order before the
update, everything will end up with the same order, instead of just adding
one to the current order.
In code:
if qs_to_increase orders are [2, 3]
{{{
qs_to_increase = qs_to_increase.order_by('-order').update(
order=F('order') + 1)
}}}
Ends up with qs_to_increse order [4,4]
{{{
qs_to_increase = qs_to_increase.update(
order=F('order') + 1)
}}}
works and gives (correctly) [3,4]
Although I think not many people will be affected (the extra .order_by was
only necessary for MySQL), it is strange that the update to MariaDB
10.5.13 results in a data error. Also, related MySQL versions (8.0?) might
also be affected.
--
Ticket URL: <https://code.djangoproject.com/ticket/34179>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/010701849ff5fdd3-be0a9a1e-debd-4f1f-a47b-35ac84901b1e-000000%40eu-central-1.amazonses.com.