#28394: BaseExpression.output_field is resolved incorrectly if source 
expressions
have directly set output_field
-------------------------------------+-------------------------------------
               Reporter:  Sergey     |          Owner:  nobody
  Fedoseev                           |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  1.11
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 {{{
 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
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28394>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.19adf2cc00bd105057ccf38d92886b4c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to