﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34942	Add icontains support for PostgreSQL ArrayField	aminabbasov	nobody	"Django ORM for PostgreSQL ArrayField allows to make only ""contains"", and doesn't support ""icontains"", although the database itself supports this type of query.

For example, I have this Product table:

{{{#!python
class Product(models.Model):
    name = models.CharField(max_length=255)
    options = ArrayField(base_field=models.CharField(max_length=255))

    def __str__(self):
        return self.name
}}}

And only two rows in table:

||= id =||= name =||= options =||
|| 1 || First || [""foo"", ""Bar"", ""BAZ""] ||
|| 2 || Second || [""Foo"", ""Bar"", ""baZ""] ||

If I want to filter rows by options сolumn, I can make only this ORM queries:

{{{#!bash
>>> Product.objects.filter(options__contains: ""foo"")
<ProductQuerySet [<Product: First>]>

>>> Product.objects.filter(options__contains: ""Bar"")
<ProductQuerySet [<Product: First>, <Product: Second>]>
}}}

But if I want to do case-insensitive filtering, {{{Product.objects.filter(options__icontains: ""foo"")}}} wouldn't work. So, the only option to do this query, is to use {{{.extra()}}} method:

{{{#!bash
>>> Product.objects.extra(
...     where=['%s ILIKE ANY (options)'],
...     params=[""foo""],
...     )
<ProductQuerySet [<Product: First>, <Product: Second>]>
}}}"	New feature	closed	Database layer (models, ORM)	4.2	Normal	wontfix	QuerySet.extra, ArrayField, PostgreSQL, icontains		Unreviewed	0	0	0	0	0	0
