﻿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
32770	Add system check for django.contrib.postgres in INSTALLED_APPS when using the fields, indexes, and constraints it provides.	Seth Yastrov	Clifford Gama	"Given the following model + index:

{{{
from django.db import models
from django.contrib.postgres.indexes import GinIndex, OpClass
from django.db.models.functions import Cast

class MyModel(models.Model):
    class Meta:
        indexes = [
            GinIndex(OpClass(Cast(""id"", output_field=models.TextField()), name='gin_trgm_ops'), name='foobar')
        ]

}}}

After running makemigrations and running the migration, it produces the SQL:

{{{
CREATE INDEX ""foobar"" ON ""myapp_mymodel"" USING gin ((CAST(""id"" AS text) gin_trgm_ops));
}}}

Which is a syntax error on Postgres (version 12). The reason is the extra parentheses around CAST."	Cleanup/optimization	closed	contrib.postgres	dev	Normal	fixed		Hannes Ljungberg Simon Charette	Ready for checkin	1	0	0	0	0	0
