From 38cada7c94f5f73d2d47a0a730ea5d71d266fa2c Mon Sep 17 00:00:00 2001 From: Ian Foote Date: Wed, 11 Oct 2017 22:55:52 +0530 Subject: Fixed #28077 -- Added support for PostgreSQL opclasses in Index. Thanks Vinay Karanam for the initial patch. --- docs/ref/models/indexes.txt | 22 +++++++++++++++++++++- docs/releases/2.2.txt | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/ref/models/indexes.txt b/docs/ref/models/indexes.txt index a78423bd36..e585a6f824 100644 --- a/docs/ref/models/indexes.txt +++ b/docs/ref/models/indexes.txt @@ -21,7 +21,7 @@ options`_. ``Index`` options ================= -.. class:: Index(fields=(), name=None, db_tablespace=None) +.. class:: Index(fields=(), name=None, db_tablespace=None, opclasses=()) Creates an index (B-Tree) in the database. @@ -72,3 +72,23 @@ in the same tablespace as the table. For a list of PostgreSQL-specific indexes, see :mod:`django.contrib.postgres.indexes`. + +``opclasses`` +------------- + +.. attribute:: Index.opclasses + +.. versionadded:: 2.2 + +The names of the `PostgreSQL operator classes +`_ to use for +this index. If you require a custom operator class, you must provide one for +each field in the index. + +For example, ``GinIndex(name='json_index', fields=['jsonfield'], +opclasses=['jsonb_path_ops'])`` creates a gin index on ``jsonfield`` using +``jsonb_path_ops``. + +``opclasses`` are ignored for databases besides PostgreSQL. + +:attr:`Index.name` is required when using ``opclasses``. diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt index 742f4893be..a68f3135e4 100644 --- a/docs/releases/2.2.txt +++ b/docs/releases/2.2.txt @@ -164,7 +164,7 @@ Migrations Models ~~~~~~ -* ... +* Added support for PostgreSQL operator classes (:attr:`.Index.opclasses`). Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.3