[Django] #33021: Migration crashes when GIN index with gin_trgm_ops is used

125 views
Skip to first unread message

Django

unread,
Aug 13, 2021, 7:58:16 AM8/13/21
to django-...@googlegroups.com
#33021: Migration crashes when GIN index with gin_trgm_ops is used
---------------------------------------------+-----------------------------
Reporter: AlekseiKhatkevich | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Keywords: gin OpClass
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+-----------------------------
I have an index like following:


{{{
GinIndex(
OpClass(Upper('text_id'), name='gin_trgm_ops'),
name='text_id_idx',
),
}}}

Migration file creates without any troubles on it.

sqlmigrate generates following SQL:

{{{
CREATE INDEX "text_id_idx" ON "auction_lot" USING gin ((UPPER("text_id")
gin_trgm_ops));
}}}

which obviously has one extra set of (), which causes following exception
during migration


{{{
django.db.utils.ProgrammingError: syntax error at or near "gin_trgm_ops"
LINE 1: ...dx" ON "auction_lot" USING gin ((UPPER("text_id") gin_trgm_o...
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33021>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 19, 2021, 12:28:52 AM8/19/21
to django-...@googlegroups.com
#33021: Migration crashes when GIN index with gin_trgm_ops is used
-------------------------------------+-------------------------------------
Reporter: Aleksei khatkevich | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: invalid

Keywords: gin OpClass | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid
* component: Migrations => Database layer (models, ORM)


Comment:

Thanks for this ticket, however you're seeing this error because of not
adding `django.contrib.postgres` to `INSTALLED_APPS`, see `OpClass()`
[https://docs.djangoproject.com/en/3.2/ref/contrib/postgres/indexes
/#opclass-expressions docs] and related ticket #32770.

--
Ticket URL: <https://code.djangoproject.com/ticket/33021#comment:1>

Reply all
Reply to author
Forward
0 new messages