Allow to emulate natural sort on mysql platforms

This commit is contained in:
Jan Böhmer 2024-06-18 21:42:00 +02:00
parent 272fe0516b
commit 123372d93f
2 changed files with 121 additions and 1 deletions

View file

@ -25,6 +25,7 @@ namespace App\Doctrine\Functions;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
@ -100,10 +101,13 @@ class Natsort extends FunctionNode
//Do the following operations only if we allow slow natural sort
if (self::$allowSlowNaturalSort) {
if ($platform instanceof SQLitePlatform) {
return $this->field->dispatch($sqlWalker).' COLLATE NATURAL_CMP';
}
if ($platform instanceof AbstractMySQLPlatform) {
return 'NatSortKey(' . $this->field->dispatch($sqlWalker) . ', 0)';
}
}
//For every other platform, return the field as is