diff options
| author | Hannes Ljungberg <hannes@5monkeys.se> | 2019-10-23 22:16:55 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-24 09:51:33 +0200 |
| commit | 318d186d7ed443d4c09745c755d4d186f9ed86d5 (patch) | |
| tree | e694d499f310474aee35659b789d1023655bd703 /django | |
| parent | b3e8dafe06691ac190ca46e190ab5c5a06c78fbe (diff) | |
[3.0.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.
Backport of fa5f3291e7f2611d53e64ab481ebe951b0161791 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/ddl_references.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/django/db/backends/ddl_references.py b/django/db/backends/ddl_references.py index d71f6169ea..44e49806f8 100644 --- a/django/db/backends/ddl_references.py +++ b/django/db/backends/ddl_references.py @@ -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)) |
