#34179 closed Bug (worksforme)

Django F expression not working as expected on MariaDB 10.5.13

Reported by: Gerben Morsink Owned by: nobody
Component: Database layer (models, ORM) Version: 4.1
Severity: Normal Keywords: mysql, mariadb
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (1)

comment:1 by Mariusz Felisiak, 17 months ago

Resolution: worksforme
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top