Opened 6 years ago

Last modified 3 years ago

#29769 closed New feature

JSONField lookup and F Objects — at Initial Version

Reported by: Gabor Körber Owned by:
Component: contrib.postgres Version:
Severity: Normal Keywords: F JSONField lookup
Cc: Srinivas Reddy Thatiparthy Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top