[Django] #30903: Creating an index with specified ordering and opclass results in syntax error

4 views
Skip to first unread message

Django

unread,
Oct 23, 2019, 4:15:50 PM10/23/19
to django-...@googlegroups.com
#30903: Creating an index with specified ordering and opclass results in syntax
error
-------------------------------------+-------------------------------------
Reporter: Hannes | Owner: Hannes Ljungberg
Ljungberg |
Type: Bug | Status: assigned
Component: Database | Version: 2.2
layer (models, ORM) |
Severity: Normal | Keywords: db-indexes
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Creating an index on postgres with both order and opclass specified
crashes with a syntax error.

{{{#!python
index = Index(
name=indexname,
fields=['-body'],
opclasses=['text_pattern_ops'],
)
}}}

{{{
django.db.utils.ProgrammingError: syntax error at or near
"text_pattern_ops"
LINE 1: ...rdered" ON "indexes_indexedarticle2" ("body" DESC text_patte...
}}}

This is because `opclass` is supposed to be inserted before `ASC | DESC`
in `CREATE INDEX`.

See https://www.postgresql.org/docs/current/sql-createindex.html

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

Django

unread,
Oct 23, 2019, 4:19:40 PM10/23/19
to django-...@googlegroups.com
#30903: Creating an index with specified ordering and opclass results in syntax
error
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes

| Ljungberg
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: db-indexes | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hannes Ljungberg):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/11966

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

Django

unread,
Oct 24, 2019, 2:17:00 AM10/24/19
to django-...@googlegroups.com
#30903: Creating an index with specified ordering and opclass results in syntax
error.

-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: assigned
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: db-indexes | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/30903#comment:2>

Django

unread,
Oct 24, 2019, 3:54:13 AM10/24/19
to django-...@googlegroups.com
#30903: Creating an index with specified ordering and opclass results in syntax
error.
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: closed

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: db-indexes | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"fa5f3291e7f2611d53e64ab481ebe951b0161791" fa5f3291]:
{{{
#!CommitTicketReference repository=""
revision="fa5f3291e7f2611d53e64ab481ebe951b0161791"
Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index
with opclasses and ordering.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30903#comment:3>

Django

unread,
Oct 24, 2019, 3:54:13 AM10/24/19
to django-...@googlegroups.com
#30903: Creating an index with specified ordering and opclass results in syntax
error.
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: db-indexes | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"318d186d7ed443d4c09745c755d4d186f9ed86d5" 318d186d]:
{{{
#!CommitTicketReference repository=""
revision="318d186d7ed443d4c09745c755d4d186f9ed86d5"
[3.0.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding


Index with opclasses and ordering.

Backport of fa5f3291e7f2611d53e64ab481ebe951b0161791 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30903#comment:4>

Django

unread,
Oct 24, 2019, 3:54:49 AM10/24/19
to django-...@googlegroups.com
#30903: Creating an index with specified ordering and opclass results in syntax
error.
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: db-indexes | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"7fe09e6d41b35d5a9a03783650249723313d3793" 7fe09e6d]:
{{{
#!CommitTicketReference repository=""
revision="7fe09e6d41b35d5a9a03783650249723313d3793"
[2.2.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding


Index with opclasses and ordering.

Backport of fa5f3291e7f2611d53e64ab481ebe951b0161791 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30903#comment:5>

Reply all
Reply to author
Forward
0 new messages