Răsfoiți Sursa

Fix SQLite GREATEST() (#8118)

* Fix SQLite GREATEST()
fix https://github.com/FreshRSS/FreshRSS/pull/8105
Related to https://github.com/FreshRSS/FreshRSS/pull/7886
Alexandre Alapetite 5 luni în urmă
părinte
comite
1b8bc1ae8b
3 a modificat fișierele cu 15 adăugiri și 1 ștergeri
  1. 5 1
      app/Models/EntryDAO.php
  2. 5 0
      app/Models/EntryDAOPGSQL.php
  3. 5 0
      app/Models/EntryDAOSQLite.php

+ 5 - 1
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)'

+ 5 - 0
app/Models/EntryDAOPGSQL.php

@@ -29,6 +29,11 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {
 		return 'ALL';
 	}
 
+	#[\Override]
+	public static function sqlGreatest(string $a, string $b): string {
+		return 'GREATEST(' . $a . ', ' . $b . ')';
+	}
+
 	#[\Override]
 	public static function sqlRandom(): string {
 		return 'RANDOM()';

+ 5 - 0
app/Models/EntryDAOSQLite.php

@@ -34,6 +34,11 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
 		return '-1';
 	}
 
+	#[\Override]
+	public static function sqlGreatest(string $a, string $b): string {
+		return 'MAX(' . $a . ', ' . $b . ')';
+	}
+
 	#[\Override]
 	public static function sqlRandom(): string {
 		return 'RANDOM()';