From 96732647dbcef4b7f5b181c59d3e6feae1ff8d7d Mon Sep 17 00:00:00 2001 From: campbell-m <87438215+campbell-m@users.noreply.github.com> Date: Sat, 20 Jul 2024 12:21:49 +0100 Subject: [PATCH] Fix TypeError --- web/lib/MRBS/DB_pgsql.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/lib/MRBS/DB_pgsql.php b/web/lib/MRBS/DB_pgsql.php index 91fb8f039c..46e19f3a7e 100644 --- a/web/lib/MRBS/DB_pgsql.php +++ b/web/lib/MRBS/DB_pgsql.php @@ -393,8 +393,10 @@ public function syntax_limit(int $count, int $offset) : string public function syntax_timestamp_to_unix(string $fieldname) : string { // A PostgreSQL timestamp can be a float. We need to round it - // to the nearest integer. - return " ROUND(DATE_PART('epoch', $fieldname)) "; + // to the nearest integer. Note that ROUND still returns a float type + // even though the value is an integer, so we need to cast it as well. + // (But the casting may round as well? If so the round is redundant.) + return " CAST(ROUND(DATE_PART('epoch', $fieldname)) AS integer) "; }