Pull-request: #19956 Fixes: #19749 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
f3d76f4066
@ -271,11 +271,14 @@ class Index
|
||||
// coming from form
|
||||
// $columns[names][]
|
||||
// $columns[sub_parts][]
|
||||
// $columns[collations][]
|
||||
foreach ($columns['names'] as $key => $name) {
|
||||
$sub_part = $columns['sub_parts'][$key] ?? '';
|
||||
$collation = $columns['collations'][$key] ?? null;
|
||||
$_columns[] = [
|
||||
'Column_name' => $name,
|
||||
'Sub_part' => $sub_part,
|
||||
'Collation' => $collation,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -17,7 +17,7 @@ class IndexColumn
|
||||
/** @var int The column sequence number in the index, starting with 1. */
|
||||
private $seqInIndex = 1;
|
||||
|
||||
/** @var string|null How the column is sorted in the index. "A" (Ascending) or NULL (Not sorted) */
|
||||
/** @var string|null How the column is sorted in the index. "A" (Ascending), "D" (Descending) or NULL (Not sorted) */
|
||||
private $collation = null;
|
||||
|
||||
/**
|
||||
|
||||
@ -2149,11 +2149,20 @@ class Table implements Stringable
|
||||
$indexFields = [];
|
||||
foreach ($index->getColumns() as $key => $column) {
|
||||
$indexFields[$key] = Util::backquote($column->getName());
|
||||
if (! $column->getSubPart()) {
|
||||
if ($column->getSubPart()) {
|
||||
$indexFields[$key] .= '(' . $column->getSubPart() . ')';
|
||||
}
|
||||
|
||||
if (! $column->getCollation()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$indexFields[$key] .= '(' . $column->getSubPart() . ')';
|
||||
$collation = $column->getCollation();
|
||||
if ($collation === 'A') {
|
||||
$indexFields[$key] .= ' ASC';
|
||||
} elseif ($collation === 'D') {
|
||||
$indexFields[$key] .= ' DESC';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($indexFields)) {
|
||||
|
||||
@ -143,6 +143,9 @@
|
||||
<th>
|
||||
{% trans 'Size' %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans 'Collation' %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% set spatial_types = [
|
||||
@ -190,6 +193,13 @@
|
||||
value="{{ index.getChoice() != 'SPATIAL' ?
|
||||
column.getSubPart() }}">
|
||||
</td>
|
||||
<td>
|
||||
<select name="index[columns][collations][]">
|
||||
<option value=""{{ column.Collation ? ' selected' }}>{% trans 'None' %}</option>
|
||||
<option value="A"{{ column.Collation == 'A' ? ' selected' }} title="ASC">A</option>
|
||||
<option value="D"{{ column.Collation == 'D' ? ' selected' }} title="DESC">D</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if add_fields > 0 %}
|
||||
@ -223,6 +233,13 @@
|
||||
name="index[columns][sub_parts][]"
|
||||
value="">
|
||||
</td>
|
||||
<td>
|
||||
<select name="index[columns][collations][]">
|
||||
<option value="" selected>{% trans 'None' %}</option>
|
||||
<option value="A" title="ASC">A</option>
|
||||
<option value="D" title="DESC">D</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user