aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-10-14 23:56:57 +0200
committerGravatar GitHub <noreply@github.com> 2025-10-14 23:56:57 +0200
commit1b8bc1ae8b9810eb66ff798093b89d2ce690373f (patch)
tree65ed76fa2ab80fbf9573e7a48909fc565eed8725
parentb7bd18148e65bbdd6be442036a295eb43ca1501e (diff)
Fix SQLite GREATEST() (#8118)
* Fix SQLite GREATEST() fix https://github.com/FreshRSS/FreshRSS/pull/8105 Related to https://github.com/FreshRSS/FreshRSS/pull/7886
-rw-r--r--app/Models/EntryDAO.php6
-rw-r--r--app/Models/EntryDAOPGSQL.php5
-rw-r--r--app/Models/EntryDAOSQLite.php5
3 files changed, 15 insertions, 1 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index f05f10f6e..6eefd684c 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -42,6 +42,10 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
return "LIMIT {$limit} OFFSET {$offset}";
}
+ public static function sqlGreatest(string $a, string $b): string {
+ return 'GREATEST(' . $a . ', ' . $b . ')';
+ }
+
public static function sqlRandom(): string {
return 'RAND()';
}
@@ -290,7 +294,7 @@ SQL;
. 'SET title=:title, author=:author, '
. (static::isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content')
. ', link=:link, date=:date, `lastSeen`=:last_seen'
- . ', `lastUserModified`=GREATEST(:last_user_modified, `lastUserModified`)'
+ . ', `lastUserModified`=' . static::sqlGreatest(':last_user_modified', '`lastUserModified`')
. ', hash=' . static::sqlHexDecode(':hash')
. ', is_read=COALESCE(:is_read, is_read)'
. ', is_favorite=COALESCE(:is_favorite, is_favorite)'
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php
index 72bdd7f3e..6211b9a6b 100644
--- a/app/Models/EntryDAOPGSQL.php
+++ b/app/Models/EntryDAOPGSQL.php
@@ -30,6 +30,11 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {
}
#[\Override]
+ public static function sqlGreatest(string $a, string $b): string {
+ return 'GREATEST(' . $a . ', ' . $b . ')';
+ }
+
+ #[\Override]
public static function sqlRandom(): string {
return 'RANDOM()';
}
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index 8bf0e2209..c272272b0 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -35,6 +35,11 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
}
#[\Override]
+ public static function sqlGreatest(string $a, string $b): string {
+ return 'MAX(' . $a . ', ' . $b . ')';
+ }
+
+ #[\Override]
public static function sqlRandom(): string {
return 'RANDOM()';
}