1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

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

This commit is contained in:
Hannes Ljungberg
2019-10-23 22:16:55 +02:00
committed by Mariusz Felisiak
parent 2a54ce72f9
commit fa5f3291e7
4 changed files with 38 additions and 5 deletions

View File

@@ -110,13 +110,14 @@ class IndexColumns(Columns):
def __str__(self):
def col_str(column, idx):
try:
col = self.quote_name(column) + self.col_suffixes[idx]
except IndexError:
col = self.quote_name(column)
# Index.__init__() guarantees that self.opclasses is the same
# length as self.columns.
return '{} {}'.format(col, self.opclasses[idx])
col = '{} {}'.format(self.quote_name(column), self.opclasses[idx])
try:
col = '{} {}'.format(col, self.col_suffixes[idx])
except IndexError:
pass
return col
return ', '.join(col_str(column, idx) for idx, column in enumerate(self.columns))