#29769: JSONField lookup and F Objects
------------------------------------+--------------------------------------
Reporter: g4borg | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version:
Severity: Normal | Resolution:
Keywords: F JSONField lookup | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Description changed by g4borg:
Old description:
> 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.
New description:
Currently, it is rather undocumented, that `F` Objects 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#comment:1>
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/064.f3b5687bab2d99dbbbe7a2ea22c4bbed%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.