Fix compatibilité MySQL : NULLS LAST et order withCount/select

- DbCompat::nullsLast() : syntaxe portable pgsql/mysql pour ORDER BY NULLS LAST
- RechercheController, ExportController : remplace 'nom ASC NULLS LAST' (pgsql only)
- CarteController : select() avant withCount() pour ne pas effacer le COUNT subquery

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 18:46:31 +02:00
parent 6271963a94
commit bc4dd29ae7
4 changed files with 17 additions and 5 deletions
+12
View File
@@ -58,6 +58,18 @@ class DbCompat
: "JSON_UNQUOTE(JSON_EXTRACT(data, '$.$jsonKey'))";
}
/**
* Fragment ORDER BY "colonne ASC, nulls en dernier".
* Usage : ->orderByRaw(DbCompat::nullsLast('nom'))
*/
public static function nullsLast(string $column, string $direction = 'ASC'): string
{
$dir = strtoupper($direction);
return self::isPgsql()
? "{$column} {$dir} NULLS LAST"
: "({$column} IS NULL) ASC, {$column} {$dir}";
}
/** Syntaxe de la colonne générée stockée pour un champ JSON imbriqué (ex: date_evenement.valeur) */
public static function generatedJsonNestedCol(string $jsonPath): string
{