mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #35235 -- Removed caching of BaseExpression._output_field_or_none.
This commit is contained in:
parent
12b9ef38b3
commit
cbb0812683
3 changed files with 37 additions and 7 deletions
|
@ -51,6 +51,7 @@ from django.db.models.expressions import (
|
|||
Combinable,
|
||||
CombinedExpression,
|
||||
NegatedExpression,
|
||||
OutputFieldIsNoneError,
|
||||
RawSQL,
|
||||
Ref,
|
||||
)
|
||||
|
@ -2329,6 +2330,16 @@ class ValueTests(TestCase):
|
|||
time = Time.objects.annotate(one=Value(1, output_field=DecimalField())).first()
|
||||
self.assertEqual(time.one, 1)
|
||||
|
||||
def test_output_field_is_none_error(self):
|
||||
with self.assertRaises(OutputFieldIsNoneError):
|
||||
Employee.objects.annotate(custom_expression=Value(None)).first()
|
||||
|
||||
def test_output_field_or_none_property_not_cached(self):
|
||||
expression = Value(None, output_field=None)
|
||||
self.assertIsNone(expression._output_field_or_none)
|
||||
expression.output_field = BooleanField()
|
||||
self.assertIsInstance(expression._output_field_or_none, BooleanField)
|
||||
|
||||
def test_resolve_output_field(self):
|
||||
value_types = [
|
||||
("str", CharField),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue