#36845: Allow negative index in Left() for PostgreSQL
-------------------------------------+-------------------------------------
     Reporter:  Christopher          |                     Type:  New
  Covington                          |  feature
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  6.0                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 PostgreSQL has supported negative indices since v9.1
 https://www.postgresql.org/docs/9.1/functions-string.html as right side
 trim length--just like Python string slicing.

 Targeting the check and ValueError in `Left.__init__()` more precisely
 will enable straightforward translation of a common string manipulation
 pattern from Python:
 `field[:-3]`

 to Django ORM for PostgreSQL:
 `Left('field', -3)`

 For other databases I would propose initially carrying forward the non-
 negative requirement. If there's interest, a Python implementation of
 negative index (right side trim length) support, or something cleverer,
 could follow up as separate discussion and work.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36845>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019b937d6d49-0fc7140f-25f0-4672-b195-d1284bd59440-000000%40eu-central-1.amazonses.com.

Reply via email to