Opened 5 years ago

Closed 5 years ago

Last modified 5 years 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 by Hannes Ljungberg, 5 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 5 years ago

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 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In fa5f3291:

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

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

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 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

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