#29769: JSONField lookup and F Objects
-------------------------------------+-------------------------------------
Reporter: g4borg | Owner: (none)
Type: New | Status: new
feature |
Component: | Version:
contrib.postgres |
Severity: Normal | Keywords: F JSONField lookup
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Currently, it is rather undocumented, that F Functions do not perform JSON
Lookups.
I suggest to either introduce a similar Object that is capable, or similar
solution to make this possible; at the very least however, I suggest to
add this information to the documentation for JSONField in django docs.
I stumbled on this when I tried to rewrite a raw statement in the form of
`SELECT fields FROM schema WHERE lower(unaccent(jsonfield->lookup->>data))
LIKE lower(searchterm) ...`
and also stumbled on stackoverflow dealing with this issue:
https://stackoverflow.com/questions/40623820/django-jsonfield-postgres-
and-f-object-comparison
Note, that if lookups in F might not easily be adaptable, the
stackoverflow question has a nice side effect of showing off a possible
complementary solution: overwrite/extend `__getitem__` for `F` objects to
deal with json / subfield lookups.
--
I thought brainstorming about such would be benefitial,
If I have overseen an already existing workaround I am eager to get
corrected.
--
Ticket URL: <https://code.djangoproject.com/ticket/29769>
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/049.89285eeaecbdb58ea85a103b974fb77c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.