[Django] #34179: Django F expression not working as expected on MariaDB 10.5.13

6 views
Skip to first unread message

Django

unread,
Nov 22, 2022, 10:30:12 AM11/22/22
to django-...@googlegroups.com
#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.

Django

unread,
Nov 22, 2022, 2:23:09 PM11/22/22
to django-...@googlegroups.com
#34179: Django F expression not working as expected on MariaDB 10.5.13
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) | Resolution:
Severity: Normal | worksforme

Keywords: mysql, mariadb | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

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


Comment:

Hi, thanks for this report, however everything works for me with MariaDB
10.5.13 (I checked tests added in
779e615e362108862f1681f965ee9e4f1d0ae6d2).

--
Ticket URL: <https://code.djangoproject.com/ticket/34179#comment:1>

Reply all
Reply to author
Forward
0 new messages