Opened 13 months ago

Last modified 5 months ago

#28077 new New feature

Allow specifying custom operator classes for PostgreSQL indexes

Reported by: IzyJeepee Owned by: nobody
Component: Database layer (models, ORM) Version: 1.11
Severity: Normal Keywords: postgres, gin, operator, class
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (5)

comment:2 Changed 13 months ago by Mads Jensen

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

comment:3 Changed 13 months ago by Tim Graham

Summary: GinIndex() and operator classAllow specifying an operator class for GinIndex()
Triage Stage: UnreviewedAccepted

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

comment:5 Changed 7 months ago 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.

comment:6 Changed 5 months ago by Tim Graham

Component: contrib.postgresDatabase layer (models, ORM)
Has patch: set
Owner: set to nobody
Summary: Allow specifying an operator class for GinIndex()Allow specifying custom operator classes for PostgreSQL indexes

#28783 was a duplicate and provides a PR.

Note: See TracTickets for help on using tickets.
Back to Top