﻿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
29844	Cast DecimalField to FloatField rounds to integer on MySQL	Ronny Vedrilla	nobody	"When I cast a DecimalField to Float, the float value gets rounded which creates wrong results.

For example is `decimalfield`=75.75 and in the annotation I see 76 in `decimalfield_float`. Seen in django 1.11.15 on MariaDB.


Model:


{{{
class MyModel(models.Model):
 floatfield = models.FloatField('My FloatField')
 decimalfield = models.DecimalField(_(""My DecimalField""), decimal_places=2, max_digits=12, validators=[MinValueValidator(Decimal('0.01'))])
}}}


Query:


{{{
MyModel.objects.all().annotate(decimalfield_float=Cast('decimalfield', FloatField()))
}}}


"	Bug	closed	Database layer (models, ORM)	1.11	Normal	duplicate			Unreviewed	0	0	0	0	0	0
