Skip to content

Commit de85bcb

Browse files
committed
Merge #19331 - Fix #17182 - FK Relationship View constraint name natural ordering
Pull-request: #19331 Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents 72287e2 + e0d983f commit de85bcb

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

docs/config.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,9 +3612,9 @@ Various display setting
36123612
:type: boolean
36133613
:default: true
36143614

3615-
Sorts database and table names according to natural order (for
3616-
example, t1, t2, t10). Currently implemented in the navigation panel
3617-
and in Database view, for the table list.
3615+
Sorts database, table names and foreign key constaint according to natural order (for
3616+
example, t1, t2, t10). Currently implemented in the navigation panel,
3617+
in Database view for the table list and Relation view while listing Foreign key constraints.
36183618

36193619
.. config:option:: $cfg['InitialSlidersState']
36203620

src/Controllers/Table/RelationController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use PhpMyAdmin\MessageType;
2020
use PhpMyAdmin\ResponseRenderer;
2121
use PhpMyAdmin\Routing\Route;
22+
use PhpMyAdmin\SqlParser\Utils\ForeignKey as ForeignKeyObject;
2223
use PhpMyAdmin\Table\Table;
2324
use PhpMyAdmin\Template;
2425
use PhpMyAdmin\UrlParams;
@@ -28,6 +29,7 @@
2829
use function array_keys;
2930
use function md5;
3031
use function strnatcasecmp;
32+
use function strnatcmp;
3133
use function uksort;
3234
use function usort;
3335

@@ -179,6 +181,13 @@ public function __invoke(ServerRequest $request): Response
179181

180182
if ($this->config->settings['NaturalOrder']) {
181183
uksort($columnArray, strnatcasecmp(...));
184+
usort(
185+
$relationsForeign,
186+
static fn (ForeignKeyObject $before, ForeignKeyObject $after) => strnatcmp(
187+
$before->constraint ?? '',
188+
$after->constraint ?? '',
189+
),
190+
);
182191
}
183192

184193
$foreignKeyRow = '';

0 commit comments

Comments
 (0)