Func Expressions and Transforms are extremely similar in API, but not
enough to be interchangeable. Transforms are 1-arity (usually -
postgres.array.IndexTransform is a notable exception) Functions with
special behaviour.
Instead of implementing a Length Func and a Length Transform, we should be
able to implement a Length Func and register that same class as a
Transform. That's not currently possible because of the slight differences
in API and behaviour. We should resolve this ASAP.
--
Ticket URL: <https://code.djangoproject.com/ticket/24629>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by jarshwah):
Experiment PR: https://github.com/django/django/pull/4482
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:2>
* 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>
Comment (by jarshwah):
The PR attached may also fix https://code.djangoproject.com/ticket/22288
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:4>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:5>
* keywords: => 1.9
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:6>
* needs_better_patch: 1 => 0
Comment:
Seems to be ready for more review as tests are now passing.
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:7>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:8>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"534aaf56f4a8e261e111426b2a709e2f8816192f" 534aaf5]:
{{{
#!CommitTicketReference repository=""
revision="534aaf56f4a8e261e111426b2a709e2f8816192f"
Fixed #24629 -- Unified Transform and Expression APIs
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:9>