diff --git a/lib/Database.php b/lib/Database.php index ae175d7d..2cb55147 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -475,7 +475,8 @@ class Database { join arsse_feeds on feed = arsse_feeds.id left join topmost on folder=f_id" ); - $q->setOrder("pinned desc, coalesce(arsse_subscriptions.title, arsse_feeds.title) collate nocase"); + $nocase = $this->db->sqlToken("nocase"); + $q->setOrder("pinned desc, coalesce(arsse_subscriptions.title, arsse_feeds.title) collate $nocase"); // define common table expressions $q->setCTE("userdata(userid)", "SELECT ?", "str", $user); // the subject user; this way we only have to pass it to prepare() once // topmost folders belonging to the user diff --git a/lib/Db/PostgreSQL/Driver.php b/lib/Db/PostgreSQL/Driver.php index e681f72c..89e7a7cb 100644 --- a/lib/Db/PostgreSQL/Driver.php +++ b/lib/Db/PostgreSQL/Driver.php @@ -113,7 +113,12 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver { } public function sqlToken(string $token): string { - return $token; + switch (strtolower($token)) { + case "nocase": + return '"und-x-icu"'; + default: + return $token; + } } public function savepointCreate(bool $lock = false): int { diff --git a/sql/PostgreSQL/2.sql b/sql/PostgreSQL/2.sql index d37fcb50..847edb70 100644 --- a/sql/PostgreSQL/2.sql +++ b/sql/PostgreSQL/2.sql @@ -4,19 +4,13 @@ -- Please consult the SQLite 3 schemata for commented version --- create a case-insensitive generic Unicode collation sequence -create collation nocase( - provider = icu, - locale = '@kf=false' -); - -alter table arsse_users alter column id type text collate nocase; -alter table arsse_folders alter column name type text collate nocase; -alter table arsse_feeds alter column title type text collate nocase; -alter table arsse_subscriptions alter column title type text collate nocase; -alter table arsse_articles alter column title type text collate nocase; -alter table arsse_articles alter column author type text collate nocase; -alter table arsse_categories alter column name type text collate nocase; -alter table arsse_labels alter column name type text collate nocase; +alter table arsse_users alter column id type text collate "und-x-icu"; +alter table arsse_folders alter column name type text collate "und-x-icu"; +alter table arsse_feeds alter column title type text collate "und-x-icu"; +alter table arsse_subscriptions alter column title type text collate "und-x-icu"; +alter table arsse_articles alter column title type text collate "und-x-icu"; +alter table arsse_articles alter column author type text collate "und-x-icu"; +alter table arsse_categories alter column name type text collate "und-x-icu"; +alter table arsse_labels alter column name type text collate "und-x-icu"; update arsse_meta set value = '3' where key = 'schema_version';