mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #35257 -- Corrected resolving output_field for IntegerField/DecimalField with NULL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
fd2514d17d
commit
6a37e9bfae
@@ -2654,6 +2654,29 @@ class CombinedExpressionTests(SimpleTestCase):
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
expr.output_field
|
||||
|
||||
def test_resolve_output_field_numbers_with_null(self):
|
||||
test_values = [
|
||||
(3.14159, None, FloatField),
|
||||
(None, 3.14159, FloatField),
|
||||
(None, 42, IntegerField),
|
||||
(42, None, IntegerField),
|
||||
(None, Decimal("3.14"), DecimalField),
|
||||
(Decimal("3.14"), None, DecimalField),
|
||||
]
|
||||
connectors = [
|
||||
Combinable.ADD,
|
||||
Combinable.SUB,
|
||||
Combinable.MUL,
|
||||
Combinable.DIV,
|
||||
Combinable.MOD,
|
||||
Combinable.POW,
|
||||
]
|
||||
for lhs, rhs, expected_output_field in test_values:
|
||||
for connector in connectors:
|
||||
with self.subTest(lhs=lhs, connector=connector, rhs=rhs):
|
||||
expr = CombinedExpression(Value(lhs), connector, Value(rhs))
|
||||
self.assertIsInstance(expr.output_field, expected_output_field)
|
||||
|
||||
def test_resolve_output_field_dates(self):
|
||||
tests = [
|
||||
# Add - same type.
|
||||
|
||||
Reference in New Issue
Block a user