#34942: Add icontains support for PostgreSQL ArrayField
-------------------------------------+-------------------------------------
Reporter: aminabbasov | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: QuerySet.extra, | Triage Stage:
ArrayField, PostgreSQL, icontains | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):
* status: new => closed
* resolution: => wontfix
Comment:
Hi aminabbasov,
Note you can write your own lookups easily with Django, there's a tutorial
on how to do that: https://docs.djangoproject.com/en/4.2/howto/custom-
lookups/
Following that guide and altering slightly so that it registers on
`ArrayField` only and swapping the rhs & lhs so it takes on the format
`arg ILIKE ANY(field)`, then your `icontains` array lookup would be
something like this:
{{{
@ArrayField.register_lookup
class ArrayIContains(Lookup):
lookup_name = "icontains"
def as_sql(self, compiler, connection):
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = rhs_params + lhs_params
return "%s ILIKE ANY(%s)" % (rhs, lhs), params
}}}
As for whether this should be part of Django: The normal process is to
bring this up on the forum and get folks to vote on its inclusion, though
consensus usually is that we don't want to include every possible kitchen
sink feature in the codebase when it's easy enough to write your own.
Please see https://code.djangoproject.com/wiki/DevelopersMailingList for
more details.
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/34942#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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018b946ee1b5-624212e3-48b1-4bc8-83e5-e4594073d6f5-000000%40eu-central-1.amazonses.com.