From 0f48ce6f3725458bbbb1a3a456771f3dea112350 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 11 Dec 2018 14:14:32 -0500 Subject: [PATCH] Use a Unicode collation for SQLite --- lib/Db/SQLite3/Driver.php | 4 ++++ sql/PostgreSQL/2.sql | 4 +--- sql/SQLite3/3.sql | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Db/SQLite3/Driver.php b/lib/Db/SQLite3/Driver.php index 5a66605..9925494 100644 --- a/lib/Db/SQLite3/Driver.php +++ b/lib/Db/SQLite3/Driver.php @@ -57,6 +57,10 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver { $this->setTimeout($timeout); // set other initial options $this->exec("PRAGMA foreign_keys = yes"); + // use a case-insensitive Unicode collation sequence + $this->collator = new \Collator("@kf=false"); + $m = ($this->db instanceof \PDO) ? "sqliteCreateCollation" : "createCollation"; + $this->db->$m("nocase", [$this->collator, "compare"]); } public static function requirementsMet(): bool { diff --git a/sql/PostgreSQL/2.sql b/sql/PostgreSQL/2.sql index 021d3cd..d37fcb5 100644 --- a/sql/PostgreSQL/2.sql +++ b/sql/PostgreSQL/2.sql @@ -4,9 +4,7 @@ -- Please consult the SQLite 3 schemata for commented version --- create a case-insensitive generic collation sequence --- this collation is Unicode-aware, whereas SQLite's built-in nocase --- collation is ASCII-only +-- create a case-insensitive generic Unicode collation sequence create collation nocase( provider = icu, locale = '@kf=false' diff --git a/sql/SQLite3/3.sql b/sql/SQLite3/3.sql index 063a2f1..bac79a8 100644 --- a/sql/SQLite3/3.sql +++ b/sql/SQLite3/3.sql @@ -19,6 +19,9 @@ create table arsse_marks( insert into arsse_marks select article,subscription,read,starred,modified,note,0 from arsse_marks_old; drop table arsse_marks_old; +-- reindex anything which uses the nocase collation sequence; it has been replaced with a Unicode collation +reindex nocase; + -- set version marker pragma user_version = 4; update arsse_meta set value = '4' where key = 'schema_version';