diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index c67062a4a7..51374cb3bb 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -257,6 +257,9 @@ class DatabaseOperations(BaseDatabaseOperations): def adapt_timefield_value(self, value): return value + def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None): + return value + def adapt_ipaddressfield_value(self, value): if value: return Inet(value) diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py index efb4ba227e..3778e32f1b 100644 --- a/tests/expressions_case/tests.py +++ b/tests/expressions_case/tests.py @@ -6,9 +6,9 @@ from uuid import UUID from django.core.exceptions import FieldError from django.db.models import ( - BinaryField, BooleanField, Case, CharField, Count, DurationField, F, - GenericIPAddressField, IntegerField, Max, Min, Q, Sum, TextField, - TimeField, UUIDField, Value, When, + BinaryField, BooleanField, Case, CharField, Count, DecimalField, + DurationField, F, GenericIPAddressField, IntegerField, Max, Min, Q, Sum, + TextField, TimeField, UUIDField, Value, When, ) from django.test import SimpleTestCase, TestCase @@ -705,7 +705,7 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.update( decimal=Case( When(integer=1, then=Decimal('1.1')), - When(integer=2, then=Decimal('2.2')), + When(integer=2, then=Value(Decimal('2.2'), output_field=DecimalField())), ), ) self.assertQuerysetEqual(