1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #32585 -- Fixed Value() crash with DecimalField on SQLite.

This commit is contained in:
Hasan Ramezani 2021-03-28 13:06:29 +02:00 committed by Mariusz Felisiak
parent dcb06c2c68
commit ed0cc52dc3
2 changed files with 6 additions and 1 deletions

View File

@ -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.

View File

@ -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),