Opened 8 months ago

Last modified 8 months ago

#35311 closed Bug

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

Reported by: Pierre Juhen Owned by: nobody
Component: Database layer (models, ORM) Version: 5.0
Severity: Normal Keywords: postgresql migration
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 Pierre Juhen)

Hi,

I created a Gin Index using :

GinIndex(OpClass(Lower('title'), name='gin_trgm_ops'), name="name_gin_trgm_title_affaire"),

makemigrations generates the following code :

migrations.AddIndex(

model_name='affaire',

index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('title'), name='gin_trgm_ops'), name='name_gin_trgm_title_affaire'),

),

SQLMIGRATE generates a wrong code :

CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING gin ((LOWER("title"), name=gin_trgm_ops));

Instead of (too many parenthesis) :

CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING gin (LOWER("title"), name=gin_trgm_ops);

There is a manual workaround, but its annoying.

Thank you.

Regards

Change History (1)

comment:1 by Pierre Juhen, 8 months ago

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