diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-01-19 00:37:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-01-22 14:34:25 +0100 |
| commit | 44cd984db9877b2a1aac3321744f7d0415f2f2e9 (patch) | |
| tree | 684fe336e2bfff84920a2c752155b5617d0d3b36 /src/lib/sqlite_database.cc | |
| parent | 16b3f6c6245acf9689349dbd2af7d4411f861767 (diff) | |
Sort cinemas and DKDM recipients correctly using the collator (#2950).
Diffstat (limited to 'src/lib/sqlite_database.cc')
| -rw-r--r-- | src/lib/sqlite_database.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/sqlite_database.cc b/src/lib/sqlite_database.cc index f0270129b..e1ad15143 100644 --- a/src/lib/sqlite_database.cc +++ b/src/lib/sqlite_database.cc @@ -24,6 +24,20 @@ #include <sqlite3.h> +using std::string; + + +static +int collator_compare(void* context, int length_a, const void* string_a, int length_b, const void* string_b) +{ + auto collator = reinterpret_cast<Collator*>(context); + return collator->compare( + string(reinterpret_cast<char const*>(string_a), length_a), + string(reinterpret_cast<char const*>(string_b), length_b) + ); +} + + SQLiteDatabase::SQLiteDatabase(boost::filesystem::path path) { #ifdef DCPOMATIC_WINDOWS @@ -36,6 +50,11 @@ SQLiteDatabase::SQLiteDatabase(boost::filesystem::path path) } sqlite3_busy_timeout(_db, 500); + + rc = sqlite3_create_collation(_db, "unicode", SQLITE_UTF8, &_collator, collator_compare); + if (rc != SQLITE_OK) { + throw std::runtime_error("Could not set SQLite database collation"); + } } |
