Skip to content

Commit

Permalink
Fixed #32585 -- Fixed Value() crash with DecimalField on SQLite.
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored and felixxm committed Mar 29, 2021
1 parent dcb06c2 commit ed0cc52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/db/models/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def copy(self):
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.
Expand Down
5 changes: 5 additions & 0 deletions tests/expressions/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,11 @@ def test_compile_unresolved(self):
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),
Expand Down

0 comments on commit ed0cc52

Please sign in to comment.