#25307: Cannot use .annotate with conditional expressions
-------------------------------------+-------------------------------------
Reporter: jproffitt | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by freshquiz):
I'm not sure when/how, but the `condition` attribute of the `When`
`Expression` gets converted to a `django.db.models.sql.where.WhereNode`,
so it's actually a `WhereNode` object that is having
`.get_source_expressions()` called on it.
Regardless, `django.db.models.expressions.When`'s
`get_source_expressions()` and `set_source_expressions()` methods need to
bridge the gap between `Expression`s and `django.utils.tree.Node`s, in
order to properly re-write the column names to the aliases from the
subquery.
I can't see a quick/easy way to do this, but as I'm not experienced in the
ORM code, I could be wrong.
--
Ticket URL: <https://code.djangoproject.com/ticket/25307#comment:7>
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/067.908f810f88c9a516eeea73c9b2258e44%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.