Opened 3 months ago
Closed 3 months ago
#36462 closed New feature (wontfix)
Document has_any_keys lookup array case for JSONField (Postgres)
Reported by: | Willem Van Onsem | Owned by: | |
---|---|---|---|
Component: | Documentation | Version: | 5.1 |
Severity: | Normal | Keywords: | orm, documentation, JSON, postgreSQL. |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Recently, there was a question on StackOverflow about how to query a JSON field that has an array, to look if the array contains at least one of the items.
A bit surprising, but the ?|
operator does that, indeed according to the docs, this use-case is not (well) documented in Django, and keys
evidently suggests that it is for dictionaries.
I'm wondering if we should include such cases in the documentation, so add an example where the JSON blob is an array of strings for example, and demonstrate how it is filtered.
Change History (1)
comment:1 by , 3 months ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Summary: | Should we include documentation for has_any_keys for the JSONField if the value is an array. → Document has_any_keys lookup array case for JSONField (Postgres) |
Thank you for the ticket. I agree we don't have documentation for this case. However, in deciding if I think this should be documented within the JSONField has_any_keys lookup docs, I found that this works for PostgreSQL but not for SQLite and Oracle (not yet tested MariaDB)
As this is PostgreSQL specific, I'm not sure adding a note for
has_key
,has_any_keys
,has_keys
for the array cases on PostgreSQL is worth it as this might be quite niche.As I can't see database specific documentation of additional usage in the docs around the lookups already, I don't think it's the norm to include this. If you feel strongly, you can start a discussion on the Django Forum and see what other people think