Merge #19956 - Fix #19749 - Descending index being converted to ascending

Pull-request: #19956
Fixes: #19749
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2026-02-08 17:40:51 +01:00
commit f3d76f4066
No known key found for this signature in database
GPG Key ID: 70684F4717D49A31
4 changed files with 32 additions and 3 deletions

View File

@ -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 {

View File

@ -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;
/**

View File

@ -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)) {

View File

@ -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 %}