[Django] #27437: Can't create GinIndex on ArrayField(CITextField)

191 views
Skip to first unread message

Django

unread,
Nov 5, 2016, 7:28:08 AM11/5/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: vad | Owner: (none)
Type: Bug | Status: new
Component: | Version: master
contrib.postgres | Keywords: postgres, indexes,
Severity: Normal | gin, citext, arrays
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have a model like:

{{{#!python
class MyModel(models.Model):
column = ArrayField(
CITextField(max_length=255),
)

class Meta:
indexes = [
GinIndex(fields=['column'], name='mygin')
]
}}}

Migration fails because:

{{{
django.db.utils.ProgrammingError: data type citext[] has no default
operator class for access method "gin"
HINT: You must specify an operator class for the index or define a
default operator class for the data type.
}}}

full trace on this
[https://gist.github.com/vad/7f0414b8a52bb288f64f6c1df6006b35 gist]. To
solve this issue an Operator Class
[http://stackoverflow.com/a/20102665/690696 must be created]

--
Ticket URL: <https://code.djangoproject.com/ticket/27437>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 7, 2016, 4:44:52 AM11/7/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage: Accepted
gin, citext, arrays |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:1>

Django

unread,
Nov 20, 2016, 12:36:11 PM11/20/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: assigned

Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage: Accepted
gin, citext, arrays |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mads Jensen):

* owner: (none) => Mads Jensen
* status: new => assigned


Comment:

I have some code, tests, and documentation for this, although the SQL code
from Stackoverflow appears to be incorrect (I get
{{{django.db.utils.InternalError: ginqueryarrayextract: unknown strategy
number: 7}}}).

--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:2>

Django

unread,
Nov 20, 2016, 1:30:07 PM11/20/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage: Accepted
gin, citext, arrays |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mads Jensen):

[https://github.com/django/django/pull/7585 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:3>

Django

unread,
Nov 20, 2016, 1:30:20 PM11/20/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage: Accepted
gin, citext, arrays |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mads Jensen):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:4>

Django

unread,
Nov 20, 2016, 2:54:24 PM11/20/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage: Accepted
gin, citext, arrays |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

As I mentioned to the reporter at DUTH I'm not convinced this a common
enough use case to ship and maintain a custom operation class.

I'd be in favor of moving the ticket to ''Someday/Maybe'' and see if this
gather any traction as both `GINIndex` and `CITextField` are new features
in the still unreleased Django 1.11.

--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:5>

Django

unread,
Nov 20, 2016, 4:43:02 PM11/20/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage: Accepted
gin, citext, arrays |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mads Jensen):

I'm a bit indifferent to how this will get treated.

--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:6>

Django

unread,
Nov 22, 2016, 1:41:29 PM11/22/16
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: postgres, indexes, | Triage Stage:
gin, citext, arrays | Someday/Maybe
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Someday/Maybe


Comment:

Yes, this looks a bit specialized. In my opinion, `contrib.postgres`
should aim for implementing things that are an ~80% use case. As Simon
said, it would be nice to have more evidence that this is common before
committing to include it. Anyway, the code is on the pull request for
anyone who would like to use it in their own project.

--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:7>

Django

unread,
Dec 31, 2021, 5:06:37 AM12/31/21
to django-...@googlegroups.com
#27437: Can't create GinIndex on ArrayField(CITextField)
-------------------------------------+-------------------------------------
Reporter: Davide Setti | Owner: Mads
| Jensen
Type: Bug | Status: closed
Component: contrib.postgres | Version: dev
Severity: Normal | Resolution: wontfix

Keywords: postgres, indexes, | Triage Stage:
gin, citext, arrays | Someday/Maybe
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => wontfix


Comment:

It's niche. Moreover the `citext`
extension[https://www.postgresql.org/docs/current/citext.html is
​discouraged since PostgreSQL 12] in favor of
[https://www.postgresql.org/docs/current/collation.html ​non-deterministic
collations] that are supported in Django 3.2+ via the new `db_collation`
argument for `CharField` and `TextField`.

--
Ticket URL: <https://code.djangoproject.com/ticket/27437#comment:8>

Reply all
Reply to author
Forward
0 new messages