Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#30903 closed Bug (fixed)

Creating an index with specified ordering and opclass results in syntax error.

Reported by: Hannes Ljungberg Owned by: Hannes Ljungberg
Component: Database layer (models, ORM) Version: 2.2
Severity: Release blocker Keywords: db-indexes
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Creating an index on postgres with both order and opclass specified crashes with a syntax error.

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

Change History (5)

comment:1 Changed 10 months ago by Hannes Ljungberg

Has patch: set

comment:2 Changed 10 months ago by felixxm

Severity: NormalRelease blocker
Summary: Creating an index with specified ordering and opclass results in syntax errorCreating an index with specified ordering and opclass results in syntax error.
Triage Stage: UnreviewedAccepted

comment:3 Changed 10 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In fa5f3291:

Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.

comment:4 Changed 10 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 318d186d:

[3.0.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.

Backport of fa5f3291e7f2611d53e64ab481ebe951b0161791 from master

comment:5 Changed 10 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 7fe09e6d:

[2.2.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.

Backport of fa5f3291e7f2611d53e64ab481ebe951b0161791 from master

Note: See TracTickets for help on using tickets.
Back to Top