Opened 8 weeks ago

Last modified 4 weeks 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: no
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 (8)

comment:1 Changed 8 weeks ago by Tim Graham

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

comment:2 Changed 8 weeks 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 7 weeks ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 7 weeks ago by Adam (Chainz) Johnson

Cc: Adam (Chainz) Johnson added

comment:5 Changed 7 weeks ago by Priyansh Saxena

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

comment:6 Changed 7 weeks ago by Josh Smeaton

Cc: josh.smeaton@… added

comment:7 Changed 6 weeks ago by Priyansh Saxena

Has patch: set

comment:8 Changed 4 weeks ago by Tim Graham

Needs documentation: unset
Needs tests: unset
Note: See TracTickets for help on using tickets.
Back to Top