Opened 11 months ago

Last modified 8 months ago

#29049 assigned New feature

Add slicing notation to F expressions

Reported by: Matthew Pava Owned by: Priyansh Saxena
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: slice F
Cc: Adam (Chainz) Johnson, josh.smeaton@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


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 ArrayFields or HStoreFields, those could utilize slicing notation in a Pythonic manner.

Change History (9)

comment:1 Changed 11 months ago by Tim Graham

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

comment:2 Changed 11 months ago by Simon Charette

I think this is a reference to 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].

comment:3 Changed 11 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 11 months ago by Adam (Chainz) Johnson

Cc: Adam (Chainz) Johnson added

comment:5 Changed 11 months ago by Priyansh Saxena

Needs documentation: set
Needs tests: set
Owner: changed from nobody to Priyansh Saxena
Status: newassigned

comment:6 Changed 11 months ago by Josh Smeaton

Cc: josh.smeaton@… added

comment:7 Changed 10 months ago by Priyansh Saxena

Has patch: set

comment:8 Changed 10 months ago by Tim Graham

Needs documentation: unset
Needs tests: unset

comment:9 Changed 8 months ago by Carlton Gibson

Patch needs improvement: set

Comments on PR.

Note: See TracTickets for help on using tickets.
Back to Top