BaseExpression.output_field is resolved incorrectly if source expressions have directly set output_field
In [1]: from django.db import models
In [2]: from django.db.models.expressions import Func
In [3]: class FuncA(Func):
...: output_field = models.CharField()
...:
In [4]: class FuncB(Func):
...: pass
...:
In [5]: expr = FuncB(FuncA(models.IntegerField()))
In [6]: expr.output_field
---------------------------------------------------------------------------
FieldError Traceback (most recent call last)
<ipython-input-6-ac0033dafa8f> in <module>()
----> 1 expr.output_field
/home/sergey/dev/django/django/utils/functional.py in __get__(self, instance, cls)
34 if instance is None:
35 return self
---> 36 res = instance.__dict__[self.name] = self.func(instance)
37 return res
38
/home/sergey/dev/django/django/db/models/expressions.py in output_field(self)
225 """Return the output type of this expressions."""
226 if self._output_field_or_none is None:
--> 227 raise FieldError("Cannot resolve expression type, unknown output_field")
228 return self._output_field_or_none
229
FieldError: Cannot resolve expression type, unknown output_field
Change History
(4)
Owner: |
changed from nobody to Sergey Fedoseev
|
Status: |
new → assigned
|
Triage Stage: |
Unreviewed → Accepted
|
Version: |
1.11 → master
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
PR