Opened 7 years ago

Closed 7 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

Description

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 by Sergey Fedoseev, 7 years ago

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

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

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