﻿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
28915	DecimalField truncates trailing zeros in the fractional part on SQLite	Raphael Michel	Sergey Fedoseev	"With Django 1.11, when reading the value of a DecimalField from the database, the Decimal is always returned with the precision of the DecimalField, i.e. if the field has 2 decimal places, I always get a Decimal with two decimal places as well.

With Django 2.0, I get a rounded decimal with no more decimal places.

Sample:

{{{
obj = Foo.objects.create(a=""bar"", d=Decimal('8.320'))
obj.refresh_from_db()

print(repr(obj.d)) 
}}}

This will output `Decimal('8.320')` on Django 1.11 but `Decimal('8.32')` on Django 2.0.


For me (and likely many others) this is quite critical: For example, if you use DecimalFields to store amounts of money in a currency that always has two places, you can just pass the databases to `localize()` and get a user-friendly representation. This is no longer possible, as you would first need to call quantize in every single place which would be quite an effort to do in a large codebasis.

Since there is no mention of this in the release notes, I believe this is an unwanted regression and hope it can be fixed in 2.0.2 or the like.

I wrote a [https://github.com/raphaelm/django/commit/6c682b619e88f69e4c75b890f8c3eed8fcd1aa87 regression test] for the problem and ran `git bisect` to identify that the problem was introduced in commit [https://github.com/django/django/commit/a146b65628e702a9a3ed5be21542ca45366fbb29 a146b6562].

I did not find a way to keep the performance gain of this commit without introducing this regression, so I strongly ask to revert that commit altogether for now (and add my regression test, if wanted) until someone has a better idea how to optimize this."	Bug	closed	Database layer (models, ORM)	2.0	Release blocker	fixed		Sergey Fedoseev	Ready for checkin	1	0	0	0	0	0
