#24629: Allow Func Expressions to be used as Transforms
-------------------------------------+-------------------------------------
Reporter: jarshwah | Owner: jarshwah
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jarshwah):
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1
Comment:
https://github.com/django/django/pull/5090 is the newest PR to tackle this
patch. It still needs some tidying up, docs, and maybe some tests. But I'm
happier with the approach used here than the previous couple we've thrown
together.
There's no bridge/compat layer here. Instead, Transforms are now handled
independently from Lookups, allowing Transform to be removed and replaced
with Func. A nice side effect of converting Transforms to expressions is
that the RHS of lookups can now be an expression, paving the way for an
object based filtering pattern similar to:
{{{
Model.objects.filter(StartsWith(F('field'), Lower(Value('my_value')))
}}}
This trivial example isn't as nice as the traditional string based
filtering, but it's easy to imagine situations where you're passing around
objects that can be used as annotations or filters, and just dumping them
straight in unaltered.
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:3>
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/066.89b2d7344085c45f304619811053934a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.