-
Hi, i use It’s hard for me to understand where exactly the problem is, on the Strapi side or on the Does the out-of-the-box compilation of |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I've put this verbatim into Google, first result: leads to https://www.sqlite.org/faq.html#q18 which says
searching this repo for "icu extension" https://github.com/search?q=repo%3AWiseLibs%2Fbetter-sqlite3+ICU+extension&type=issues So the answer to your question is no, but you can load an extension or create a custom build Edit: you can also easily test this yourself import Database from 'better-sqlite3'
const db = new Database(':memory:');
console.log(db.prepare(`SELECT 'a' == 'A'`).get());
console.log(db.prepare(`SELECT 'a' == 'A' COLLATE NOCASE`).get());
console.log(db.prepare(`SELECT 'э' == 'Э'`).get());
console.log(db.prepare(`SELECT 'э' == 'Э' COLLATE NOCASE`).get());
|
Beta Was this translation helpful? Give feedback.
-
Круто, я думаю, вот это решит проблему: |
Beta Was this translation helpful? Give feedback.
-
Edit: I now notice that this discussion is about searching and not sorting, which was what I was the issue I was facing. I'll leave this here, as it is still somewhat relevant. I solved this issue of sorting unicode text using a user-defined function: sqlite_db.function('js_normalize', ((str: string) => {
const normalized = str
// Ignore case.
.toLowerCase()
/*
* 1. Decompose the string into its base characters and diacritics.
* 2. Remove all diacritics.
*
* This prevents accented characters from sorting after 'z' in Unicode order.
*
* Without normalization:
* lang
* laser
* lång ← å (U+00E5) sorts after all basic Latin letters
*
* With normalization:
* lang
* lång ← treated as "lang" for sorting
* laser
*
* Unfortunatly this is not perfect as it is blind to diacritics and will not move them around.
* E.g. it won't move the lång to the end of this list.
* lang
* lång
* lang
*
* This is better than sorting all diacritics as last, and it beats having to build and load a custom collation.
*/
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '');
return normalized;
}) as any); And you use it like this: SELECT
*,
js_normalize(name) as normalized_name
FROM products
ORDER BY normalized_name ASC |
Beta Was this translation helpful? Give feedback.
I've put this verbatim into Google, first result:
https://stackoverflow.com/questions/3465118/nhibernate-sqlite-and-cyrillic-characters-case-sensitivity-and-fallback-queri
leads to
https://www.sqlite.org/faq.html#q18
which says