Opened 2 years ago

Closed 2 years ago

#28382 closed Bug (fixed)

BaseExpression.output_field should not be set after BaseExpression._resolve_output_field() fails

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: Database layer (models, ORM) Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In [1]: from django.db.models.expressions import Value, Func
In [2]: from django.db.models import IntegerField, FloatField
In [3]: expr = Func(Value(1, output_field=IntegerField()), Value(1, output_field=FloatField()))
In [4]: expr.output_field # raises FieldError
In [5]: expr.output_field                        
Out[5]: <django.db.models.fields.IntegerField> 

Change History (2)

comment:1 Changed 2 years ago by Sergey Fedoseev

Has patch: set
Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 29769a9:

Fixed #28382 -- Prevented BaseExpression._output_field from being set if _resolve_output_field() fails.

Note: See TracTickets for help on using tickets.
Back to Top