#24485: Support for annotate(end=F('start') + F('duration'),
output_field=DateTimeField)
-------------------------------------+-------------------------------------
Reporter: yoyoma | Owner: jarshwah
Type: New feature | Status: closed
Component: Database layer | Version: 1.8beta2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: durationfield, | Triage Stage: Ready for
aggregation, annotation | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by carljm):
I think the documented solution is fine from an API perspective (the
general approach of wrapping the entire construct in something with an
`output_field` argument seems right), except that `ExpressionNode` is a
bit of an internal-feeling name.
I don't think using `F` would be a clarity improvement - the expression
may include fields, but as a whole it is not a field.
I still think the best name for the wrapper would be simply `Expression`,
since that's what the whole thing is; it's too bad that name is already
taken by something with an incompatible signature. From an API perspective
(not considering internals), I think it would be quite sensible to be able
to instantiate an `Expression` with nothing more than a sub-expression and
an output field (rather than requiring a lhs, connector and rhs), but in
terms of the implementation that would essentially mean having the
`Expression` constructor return an `ExpressionNode`, which doesn't work.
The implementation of `Expression` is quite tied to having both an lhs and
rhs.
Importing `ExpressionNode` as `Expr` might be a small improvement, but
results in having both `Expr` and `Expression`, which differ in a way
that's not at all indicated by their names. That's not great either.
I don't have a better proposal, and I agree that if this is an edge use
case we can just live with documenting `ExpressionNode` for now, and maybe
for good. Just wanted to get these API thoughts down in case we ever do
revisit.
--
Ticket URL: <https://code.djangoproject.com/ticket/24485#comment:13>
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/064.3113d46a58eb70f6827952cacd9dc2f3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.