[Django] #24629: Allow Func Expressions to be used as Transforms

19 views
Skip to first unread message

Django

unread,
Apr 11, 2015, 10:13:40 AM4/11/15
to django-...@googlegroups.com
#24629: Allow Func Expressions to be used as Transforms
-------------------------------------+-------------------------------------
Reporter: jarshwah | Owner: jarshwah
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I can't seem to find a ticket mentioning this, though we have discussed it
before. Please close if you can find a related ticket.

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.

Django

unread,
Apr 11, 2015, 10:18:05 AM4/11/15
to django-...@googlegroups.com
#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:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by jarshwah):

Experiment PR: https://github.com/django/django/pull/4482

--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:1>

Django

unread,
Apr 13, 2015, 12:41:17 PM4/13/15
to django-...@googlegroups.com
#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: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:2>

Django

unread,
Aug 7, 2015, 8:29:36 AM8/7/15
to django-...@googlegroups.com
#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

unread,
Aug 20, 2015, 1:48:31 AM8/20/15
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------

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>

Django

unread,
Aug 26, 2015, 2:43:23 AM8/26/15
to django-...@googlegroups.com
#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: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jarshwah):

* 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>

Django

unread,
Aug 29, 2015, 10:09:55 AM8/29/15
to django-...@googlegroups.com
#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: 1.9 | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* keywords: => 1.9


* needs_better_patch: 0 => 1

* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:6>

Django

unread,
Sep 17, 2015, 7:30:30 PM9/17/15
to django-...@googlegroups.com
#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: 1.9 | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* 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>

Django

unread,
Sep 18, 2015, 1:10:36 PM9/18/15
to django-...@googlegroups.com
#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: 1.9 | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/24629#comment:8>

Django

unread,
Sep 21, 2015, 5:57:23 AM9/21/15
to django-...@googlegroups.com
#24629: Allow Func Expressions to be used as Transforms
-------------------------------------+-------------------------------------
Reporter: jarshwah | Owner: jarshwah
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: 1.9 | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Josh Smeaton <josh.smeaton@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages