[Django] #28077: GinIndex() and operator class

73 views
Skip to first unread message

Django

unread,
Apr 13, 2017, 9:03:39 AM4/13/17
to django-...@googlegroups.com
#28077: GinIndex() and operator class
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: (none)
Type: New | Status: new
feature |
Component: | Version: 1.11
contrib.postgres | Keywords: postgres, gin,
Severity: Normal | operator, class
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hello,

I want use the GinIndex method to create a gin index with the django's
migration. But while the migration, I have this errror :

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

This error may be resolved by enabling the btree_gin extension.

It is possible to pass the operator class during the index's creation ?
For example :

{{{
class Meta:
indexes = [
GinIndex(fields=['my_field'], name='my_index_gin',
operator_class='my_operator')
]
}}}

Thanks

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

Django

unread,
Apr 14, 2017, 3:14:06 AM4/14/17
to django-...@googlegroups.com
#28077: GinIndex() and operator class
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage:
operator, class | Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by erickzeto):

thanks for sharing!

I'll have a same problem!

Following topics
https://vehiclepad.com/favicon.png

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

Django

unread,
Apr 14, 2017, 5:18:23 AM4/14/17
to django-...@googlegroups.com
#28077: GinIndex() and operator class
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage:
operator, class | Unreviewed
Has patch: 0 | Needs documentation: 0

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

Comment (by Mads Jensen):

#27437 looks like it's overlapping a little bit.

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

Django

unread,
Apr 15, 2017, 9:03:06 AM4/15/17
to django-...@googlegroups.com
#28077: Allow specifying an operator class for GinIndex()

-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
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


Comment:

I don't have much expertise here about the use cases and how this might
interact with #27437. Tentatively accepting for further investigation.

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

Django

unread,
Apr 17, 2017, 5:14:12 AM4/17/17
to django-...@googlegroups.com
#28077: Allow specifying an operator class for GinIndex()
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
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/mjtamlyn/django/blob/5ae3c70b405486fb81bcbf33b209f1301fade246/django/db/backends/postgresql/schema.py#L31-L35
so the issue of this may already being worked on?

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

Django

unread,
Oct 11, 2017, 4:18:19 AM10/11/17
to django-...@googlegroups.com
#28077: Allow specifying an operator class for GinIndex()
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
Has patch: 0 | Needs documentation: 0

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

Comment (by vinay karanam):

I've a use case where I am always doing `__contains` query on `JSONField`.
So, I would prefer GIN index to be created using `jsonb_path_ops` operator
class rather than the default `jsonb_ops`.

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

Django

unread,
Dec 28, 2017, 11:31:31 AM12/28/17
to django-...@googlegroups.com
#28077: Allow specifying custom operator classes for PostgreSQL indexes
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: nobody

Type: New feature | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |

Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
Has patch: 1 | Needs documentation: 0

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

* owner: (none) => nobody
* has_patch: 0 => 1
* component: contrib.postgres => Database layer (models, ORM)


Comment:

#28783 was a duplicate and provides a
[https://github.com/django/django/pull/9332 PR].

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

Django

unread,
May 26, 2018, 7:59:13 AM5/26/18
to django-...@googlegroups.com
#28077: Allow specifying custom operator classes for PostgreSQL indexes
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: Ian Foote
Type: New feature | Status: assigned

Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
Has patch: 1 | Needs documentation: 0

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

* owner: nobody => Ian Foote
* status: new => assigned


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

Django

unread,
May 27, 2018, 8:21:30 AM5/27/18
to django-...@googlegroups.com
#28077: Allow specifying custom operator classes for PostgreSQL indexes
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: Ian Foote
Type: New feature | Status: assigned
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
Has patch: 1 | Needs documentation: 0

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

Comment (by Ian Foote):

I've noticed that in the
[https://github.com/django/django/blob/master/django/contrib/gis/db/backends/postgis/schema.py#L23-L41
postgis schema editor], we have custom index creation code for single-
field indexes for {{{geodetic}}} fields. For example, we set the
{{{GIST_GEOMETRY_OPS_ND}}} operator class for fields with dimension higher
than two.

It would probably be good to refactor to allow this custom code to
integrate with the operator class support I've added, but I'm not familiar
enough with postgis to be confident making a change without guidance.

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

Django

unread,
Jun 29, 2018, 5:17:00 PM6/29/18
to django-...@googlegroups.com
#28077: Allow specifying custom operator classes for PostgreSQL indexes
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: Ian Foote
Type: New feature | Status: closed

Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
Has patch: 1 | Needs documentation: 0

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

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


Comment:

In [changeset:"38cada7c94f5f73d2d47a0a730ea5d71d266fa2c" 38cada7]:
{{{
#!CommitTicketReference repository=""
revision="38cada7c94f5f73d2d47a0a730ea5d71d266fa2c"
Fixed #28077 -- Added support for PostgreSQL opclasses in Index.

Thanks Vinay Karanam for the initial patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28077#comment:9>

Django

unread,
Jun 17, 2020, 4:33:13 AM6/17/20
to django-...@googlegroups.com
#28077: Allow specifying custom operator classes for PostgreSQL indexes
-------------------------------------+-------------------------------------
Reporter: IzyJeepee | Owner: Ian Foote
Type: New feature | Status: closed
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: postgres, gin, | Triage Stage: Accepted
operator, class |
Has patch: 1 | Needs documentation: 0

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

Comment (by GitHub <noreply@…>):

In [changeset:"82da72b74851808c08ec98fe609efe52609f29ad" 82da72b]:
{{{
#!CommitTicketReference repository=""
revision="82da72b74851808c08ec98fe609efe52609f29ad"
Refs #28077 -- Added opclasses to Index.__repr__().

This also removes unnecessary commas between attributes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28077#comment:10>

Reply all
Reply to author
Forward
0 new messages