#27824: Cannot chain unaccent transform with key lookup in Postgres JSON field
-------------------------------------+-------------------------------------
     Reporter:  Aymeric Augustin     |                    Owner:  Simon
                                     |  Charette
         Type:  New feature          |                   Status:  assigned
    Component:  contrib.postgres     |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Ole Laursen):

 * cc: olau@… (added)


Comment:

 As someone who's been using the JSONField to store user-defined fields and
 now need to query those fields, I think there needs be some kind of
 decision of what the future of querying JSONField is, perhaps followed by
 some backwards-incompatible changes to get to that state.

 As far as I can tell, from the start querying has not produced correct SQL
 outside a limited set of examples. For things that are obviously
 ambigious, the documentation basically refers to something designed for
 the much simpler HStoreField. So I don't think this has ever been fully
 baked.

 Here's my proposal:

 1) Add a couple of convenient chaining functions for accessing arbitrarly
 named stuff inside the JSON - no `__` ambigious non-sense, this should let
 me specify exactly what I'm looking for/translate directly into SQL

 2a) Let Django interpret `foo__bar` as if it were Django models - so in
 the case of unaccent, if you named your field unaccent, you'll have to
 rename it on Django upgrade or go to step 1)

 or

 2b) Let Django interpret `foo__bar` as if it were Django models, but don't
 support anything else than array/object lookups into the JSON, everything
 else is step 1)

 or

 2c) Stop interpreting stuff inside JSONField, so no `__` support

 The documentation should explain 1) but say that 2) is an option for
 simple cases as long as you're in full control of the JSON/query
 parameters.

 (I realize this is probably a discussion for django-devel, but I don't
 have time to raise it there myself right now, so just want to get
 something out there.)

--
Ticket URL: <https://code.djangoproject.com/ticket/27824#comment:9>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.47d440189066b369916b030da61fc765%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to