﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34179	Django F expression not working as expected on MariaDB 10.5.13	Gerben Morsink	nobody	"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."	Bug	closed	Database layer (models, ORM)	4.1	Normal	worksforme	mysql, mariadb		Unreviewed	0	0	0	0	0	0
