#34552: Delaying get_from_clause call as much as possible.
-------------------------------------+-------------------------------------
Reporter: Matthew Schinckel | Owner: Matthew
| Schinckel
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Matthew Schinckel):
Hi Simon, thanks for your input.
It's been ages since I actually implemented it, and the resolving of the
expression during the compilation phase was (IIRC) more a pragmatic thing:
Field instances are not resolved (because they already belong to a
model/query), instead they provide a "Col" instance to the query directly.
Normally, during a `.annotate(x=expression)`, the expression is resolved
at this point. However, because the query object does not exist at the
point where we build the Col instance, I'm not able to force a join (if
one does not exist) at that point.
In some sense part of this idea is to provide syntactic sugar for "always
apply an annotation", but it's a bit more than that (in the sense that it
also recalculates the value in python upon reference). As such I'm not
exactly sure if being able to apply the alias to the queryset(s) would be
sufficient.
Anyway, it's time to put my kids to bed; I'll try to have a bit more of a
think about it later.
--
Ticket URL: <https://code.djangoproject.com/ticket/34552#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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701880abc9fa0-f27ac99a-c6cf-41ee-9e2e-02796f20153a-000000%40eu-central-1.amazonses.com.