Browse Source

Use PosgreSQL's existing general Unicode collation

All collations appear to be case-insensitive
J. King 3 months ago
parent
commit
50f92625ef
3 changed files with 16 additions and 15 deletions
  1. 2
    1
      lib/Database.php
  2. 6
    1
      lib/Db/PostgreSQL/Driver.php
  3. 8
    13
      sql/PostgreSQL/2.sql

+ 2
- 1
lib/Database.php View File

@@ -475,7 +475,8 @@ class Database {
475 475
                 join arsse_feeds on feed = arsse_feeds.id
476 476
                 left join topmost on folder=f_id"
477 477
         );
478
-        $q->setOrder("pinned desc, coalesce(arsse_subscriptions.title, arsse_feeds.title) collate nocase");
478
+        $nocase = $this->db->sqlToken("nocase");
479
+        $q->setOrder("pinned desc, coalesce(arsse_subscriptions.title, arsse_feeds.title) collate $nocase");
479 480
         // define common table expressions
480 481
         $q->setCTE("userdata(userid)", "SELECT ?", "str", $user);  // the subject user; this way we only have to pass it to prepare() once
481 482
         // topmost folders belonging to the user

+ 6
- 1
lib/Db/PostgreSQL/Driver.php View File

@@ -113,7 +113,12 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
113 113
     }
114 114
 
115 115
     public function sqlToken(string $token): string {
116
-        return $token;
116
+        switch (strtolower($token)) {
117
+            case "nocase":
118
+                return '"und-x-icu"';
119
+            default:
120
+                return $token;
121
+        }
117 122
     }
118 123
 
119 124
     public function savepointCreate(bool $lock = false): int {

+ 8
- 13
sql/PostgreSQL/2.sql View File

@@ -4,19 +4,13 @@
4 4
 
5 5
 -- Please consult the SQLite 3 schemata for commented version
6 6
 
7
-create collation nocase(
8
-    provider = icu,
9
-    locale = '@kf=false'
10
-);
11
-
12
-alter table arsse_users alter column id type text collate nocase;
13
-alter table arsse_folders alter column name type text collate nocase;
14
-alter table arsse_feeds alter column title type text collate nocase;
15
-alter table arsse_subscriptions alter column title type text collate nocase;
16
-alter table arsse_articles alter column title type text collate nocase;
17
-alter table arsse_articles alter column author type text collate nocase;
18
-alter table arsse_categories alter column name type text collate nocase;
19
-alter table arsse_labels alter column name type text collate nocase;
7
+alter table arsse_users alter column id type text collate "und-x-icu";
8
+alter table arsse_folders alter column name type text collate "und-x-icu";
9
+alter table arsse_feeds alter column title type text collate "und-x-icu";
10
+alter table arsse_subscriptions alter column title type text collate "und-x-icu";
11
+alter table arsse_articles alter column title type text collate "und-x-icu";
12
+alter table arsse_articles alter column author type text collate "und-x-icu";
13
+alter table arsse_categories alter column name type text collate "und-x-icu";
14
+alter table arsse_labels alter column name type text collate "und-x-icu";
20 15
 
21 16
 update arsse_meta set value = '3' where key = 'schema_version';

Loading…
Cancel
Save