In the test suite, the unexpected output types encountered seem to be
`DurationField` and `IntegerField`, so a more thorough message might be
something like:
`Expression repr(self) contained mixed types: DateField, DurationField.
DurationField was unexpected; you must set the output_field= for this
Expression to either DurationField(), DateField() or ...` (''??? I dunno,
some concrete explanation of what the output_field has to be/implement if
you're not going to use any of the builtins'')
The merit of including the repr is arguable, as the `Expression` may not
what the user put in (eg: in the test suite it always seems to be a
`CombinedExpression(lhs, connector, rhs)`) but it gives more of a hint in
a query which contains multiple expressions (either nested or separate) as
to which one is actually causing the problem vs just being told "something
was wrong. Put an output_field= everywhere until it ceases, your guess is
as good as mine"; at the very least the word Expression could be replaced
with the class name which is actually raising it.
--
Ticket URL: <https://code.djangoproject.com/ticket/30548>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
* easy: 0 => 1
Comment:
Agreed, we can add types to this exception but I would like to keep it
simple, e.g. "''Expression contains mixed types: FloatField, IntegerField.
You must set output_field to IntegerField.''"
--
Ticket URL: <https://code.djangoproject.com/ticket/30548#comment:1>
* owner: nobody => Shubham Bhagat
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30548#comment:2>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/11457 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/30548#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"34f8eeea4aaed37e1d02915b76c18892c8c1718e" 34f8eeea]:
{{{
#!CommitTicketReference repository=""
revision="34f8eeea4aaed37e1d02915b76c18892c8c1718e"
Fixed #30548 -- Improved exception when expression contains mixed types.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30548#comment:4>