Opened 7 months ago

Last modified 7 months ago

#35262 closed Bug

Addindex operation generates wrong sql code for Postgresql GinIndex — at Version 1

Reported by: Pierre Juhen Owned by: nobody
Component: contrib.postgres Version: 5.0
Severity: Normal Keywords:
Cc: Pierre Juhen Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

I have created a Gin Index using the folowing code in models.py

GinIndex(OpClass(Lower('historique'), name='gin_trgm_ops'), name="name_gin_trgm_histo_affaire")

It generates a migration operation :

migrations.AddIndex(
    model_name='affaire',
    index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('historique'), name='gin_trgm_ops'), name='name_gin_trgm_histo_affaire'),
)

The SQL generated instruction is :

CREATE INDEX "name_gin_trgm_histo_affaire" ON "affaires_affaire" USING gin ((LOWER("historique") gin_trgm_ops));

It is refused by postgresql.

The right code might be :

CREATE INDEX "name_gin_trgm_histo_affaire" ON "affaires_affaire" USING gin (LOWER("historique") );

that accepted by postgresql.

Change History (1)

comment:1 by Tim Graham, 7 months ago

Component: Uncategorizedcontrib.postgres
Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top