Opened 8 months ago
Last modified 8 months ago
#35311 closed Bug
Addindex operation generates wrong sql code for Postgresql GinIndex — at Initial Version
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
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")));
Instead of (too many parenthesis) :
CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING gin (LOWER("title"));
There is a manual workaround, but its annoying.
Thank you.
Regards