diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py index e5291ab8d3..bdd23617ac 100644 --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -707,7 +707,7 @@ class Func(SQLiteNumericMixin, Expression): return copy -class Value(Expression): +class Value(SQLiteNumericMixin, Expression): """Represent a wrapped value as a node within an expression.""" # Provide a default value for `for_save` in order to allow unresolved # instances to be compiled until a decision is taken in #25425. diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index eb1bfdc2be..9b88c94d7b 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1757,6 +1757,11 @@ class ValueTests(TestCase): value = Value('foo', output_field=CharField()) self.assertEqual(value.as_sql(compiler, connection), ('%s', ['foo'])) + def test_output_field_decimalfield(self): + Time.objects.create() + time = Time.objects.annotate(one=Value(1, output_field=DecimalField())).first() + self.assertEqual(time.one, 1) + def test_resolve_output_field(self): value_types = [ ('str', CharField),