Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,20 @@ public function table_sql(string $table_name): string
break;
}

$line .= ' (`' . implode('`, `', $index['columns']) . '`)';
$index_columns = [];

foreach ($index['columns'] as $index_column) {
// A column can be indexed by its first so many characters.
// The count belongs after the name rather than inside it,
// so it has to be left outside the quoting.
if (preg_match('~^(.+)\((\d+)\)$~', $index_column, $matches) === 1) {
$index_columns[] = '`' . $matches[1] . '`(' . $matches[2] . ')';
} else {
$index_columns[] = '`' . $index_column . '`';
}
}

$line .= ' (' . implode(', ', $index_columns) . ')';

$inner_lines[] = $line;
}
Expand Down