[Django] #29049: Add slicing notation to F expressions

39 views
Skip to first unread message

Django

unread,
Jan 22, 2018, 6:28:36 PM1/22/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew | Owner: nobody
Pava |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords: slice F
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
For fields that are string expressions, the slicing notation should
utilize database functions `Substr`, `Left`, and `Right`. Those functions
could even be deprecated to require the use of slicing notation.

For fields that are iterable expressions, such as `ArrayField`s or
`HStoreField`s, those could utilize slicing notation in a Pythonic manner.

--
Ticket URL: <https://code.djangoproject.com/ticket/29049>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 24, 2018, 12:46:53 PM1/24/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:

Keywords: slice F | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by Tim Graham):

Could you give an example of what the syntax would look like?

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

Django

unread,
Jan 24, 2018, 1:44:57 PM1/24/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by Simon Charette):

I think this is a reference to [https://groups.google.com/d/msg/django-
developers/PsHDk1doTDg/B8iPrpgFAQAJ my post on the developers mailing
list].

That would be `F('textfield')[0:5]` which would map to `SubStr` and
`F('arrayfield')[0:10]` which would map to PostgreSQL `arrayfield[1:10]`.

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

Django

unread,
Jan 27, 2018, 9:37:43 AM1/27/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:3>

Django

unread,
Jan 29, 2018, 11:51:12 AM1/29/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* cc: Adam (Chainz) Johnson (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:4>

Django

unread,
Jan 30, 2018, 8:08:19 AM1/30/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: New feature | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

* owner: nobody => Priyansh Saxena
* needs_docs: 0 => 1
* status: new => assigned
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:5>

Django

unread,
Jan 30, 2018, 5:17:12 PM1/30/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

* cc: josh.smeaton@… (added)


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

Django

unread,
Feb 6, 2018, 5:08:07 PM2/6/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/9670 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:7>

Django

unread,
Feb 20, 2018, 6:59:31 PM2/20/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_docs: 1 => 0
* needs_tests: 1 => 0


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

Django

unread,
Apr 19, 2018, 5:20:02 AM4/19/18
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


Comment:

Comments on PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:9>

Django

unread,
Apr 13, 2019, 7:30:08 AM4/13/19
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Niclas
| Olofsson

Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* owner: Priyansh Saxena => Niclas Olofsson


Comment:

Taking over this since the current asignee hasn't worked on it in a while.

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:10>

Django

unread,
Apr 13, 2019, 10:20:28 AM4/13/19
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Niclas
| Olofsson
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


Comment:

New PR: https://github.com/django/django/pull/11208

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:11>

Django

unread,
Jan 29, 2020, 4:30:23 AM1/29/20
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Niclas
| Olofsson
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:12>

Django

unread,
Jun 29, 2020, 5:38:23 AM6/29/20
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Niclas
| Olofsson
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sergey Fedoseev):

* cc: Sergey Fedoseev (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:13>

Django

unread,
Jun 30, 2020, 8:36:40 AM6/30/20
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: (none)

Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Niclas Olofsson):

* owner: Niclas Olofsson => (none)
* status: assigned => new


Comment:

Since feedback on the review came 10 months after I submitted the patch,
and it now has been more than a year since it was submitted, it would be
too much of an effort for me to put my mind into this again and get it
into a mergable state.

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:14>

Django

unread,
Jun 30, 2020, 1:11:23 PM6/30/20
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Sergey
| Fedoseev

Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sergey Fedoseev):

* owner: (none) => Sergey Fedoseev


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:15>

Django

unread,
Aug 3, 2021, 1:57:56 AM8/3/21
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: David
| Smith

Type: New feature | Status: assigned
Component: Database layer | Version: dev

(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Smith):

* owner: Sergey Fedoseev => David Smith


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:16>

Django

unread,
Aug 3, 2021, 2:10:11 AM8/3/21
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: David
| Smith
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sergey Fedoseev):

* cc: Sergey Fedoseev (removed)


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:17>

Django

unread,
Oct 19, 2021, 2:08:46 PM10/19/21
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: David
| Smith
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:18>

Django

unread,
Oct 21, 2021, 1:35:53 AM10/21/21
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: David
| Smith
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:19>

Django

unread,
Nov 9, 2021, 6:33:23 AM11/9/21
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: David
| Smith
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:20>

Django

unread,
Nov 1, 2022, 11:22:15 AM11/1/22
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Abhinav
| Yadav

Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* owner: David Smith => Abhinav Yadav


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:21>

Django

unread,
Nov 8, 2022, 5:09:12 AM11/8/22
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Abhinav
| Yadav
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Abhinav Yadav):

I have been reading up about this issue to continue and finish it off from
where David left it, and I have some doubts. The SQL query left by Felix
[https://github.com/django/django/pull/14731#discussion_r745505740 in this
comment] also doesn't generate any QuerySet or objects. I tried to run
that query using `Manager.raw()`, which generated no results.

Further I investigated the `resolve_expression` method of `SliceableF`
class in `django/db/models/expressions.py`, and compared it to other
implementations of resovle_expression method in other classes but couldn't
find anything concrete which might point to where the error might be.

Does a special method for handling slicing and indexing for OuterRef query
need to be written so it is properly resolved? That is what I'm thinking
because I can't find anything else that is properly handling slicing for
OuterRef Queries, unless I'm missing something.

Also should `None` be used instead of `''` in slice_expression for end if
length is not provided?

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:22>

Django

unread,
Nov 18, 2022, 4:24:41 PM11/18/22
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Abhinav
| Yadav
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


Comment:

[https://github.com/django/django/pull/16310 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:23>

Django

unread,
Nov 20, 2022, 11:25:26 PM11/20/22
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Abhinav
| Yadav
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:24>

Django

unread,
Dec 11, 2023, 7:36:11 AM12/11/23
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Nick Pope

Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* owner: Abhinav Yadav => Nick Pope


* needs_better_patch: 1 => 0


Comment:

New [https://github.com/django/django/pull/17596 PR] with some fixes.
Hopefully we can finally get this over the line...

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:25>

Django

unread,
Dec 30, 2023, 2:17:50 AM12/30/23
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Nick Pope
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: slice F | 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 Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:26>

Django

unread,
Dec 30, 2023, 2:24:39 AM12/30/23
to django-...@googlegroups.com
#29049: Add slicing notation to F expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Nick Pope
Type: New feature | Status: closed

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: slice F | 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 GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"94b6f101f7dc363a8e71593570b17527dbb9f77f" 94b6f10]:
{{{
#!CommitTicketReference repository=""
revision="94b6f101f7dc363a8e71593570b17527dbb9f77f"
Fixed #29049 -- Added slicing notation to F expressions.

Co-authored-by: Priyansh Saxena <askpr...@gmail.com>
Co-authored-by: Niclas Olofsson <n...@niclasolofsson.se>
Co-authored-by: David Smith <smi...@gmail.com>
Co-authored-by: Mariusz Felisiak <felisiak...@gmail.com>
Co-authored-by: Abhinav Yadav <abhinav....@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29049#comment:27>

Reply all
Reply to author
Forward
0 new messages