Opened 8 months ago
Closed 8 months ago
#35311 closed Bug (duplicate)
Addindex operation generates wrong sql code for Postgresql GinIndex — at Version 2
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 )
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 (2)
comment:1 by , 8 months ago
Description: | modified (diff) |
---|
comment:2 by , 8 months ago
Description: | modified (diff) |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Duplicate of #33021.
django.contrib.postgres
must be inINSTALLED_APPS
when usingOpClass()
. See docs and related ticket #32770.