From d428119f4fd666992237d8f45616cb8d8e19af7a Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 10 Jan 2024 11:37:10 -0700 Subject: [PATCH] Fix natural_sort cast to text If item being sorted is numeric data type need to cast to text. This would usually be fixed during the upgrade. However BDR prevents using standard alter table data type commands. --- resources/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/functions.php b/resources/functions.php index 9fbcd476da..38d09bbf78 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2099,7 +2099,7 @@ $dir = !empty($dir) && strtolower($dir) == 'desc' ? 'desc' : 'asc'; if (!empty($col)) { if ($sort == 'natural' && $db_type == "pgsql") { - return $order_by . 'natural_sort(' . $col . ') ' . $dir . ' '; + return $order_by . 'natural_sort(' . $col . '::text) ' . $dir . ' '; } else { return $order_by . $col . ' ' . $dir . ' '; } @@ -2114,7 +2114,7 @@ } } else { if ($sort == 'natural' && $db_type == "pgsql") { - return $order_by . 'natural_sort(' . $col_default . ') ' . $dir_default . ' '; + return $order_by . 'natural_sort(' . $col_default . '::text) ' . $dir_default . ' '; } else { return $order_by . $col_default . ' ' . $dir_default . ' '; } @@ -2395,4 +2395,4 @@ if (!function_exists('git_find_repos')) { } } -?> \ No newline at end of file +?>