Making Ankisync compatible with the new Anki database
patarapolw opened this issue · 4 comments
Does anyone know how to get over unicase collation
?
sqlite3.OperationalError: no such collation sequence: unicase
It seems to be based on Rust SQLite.
Solved with .where(Model.col_name.collate("NOCASE") == "xxx")
(or "BINARY"
)
I'm not familiar with this project, but just ran into the same issue on my own project and found this issue. I solved the issue by registering a new collation named unicase after opening my sqlite connection. Unicase is a complex beast that replaces out unicode characters so that strings like Maße and MASSE are considered equal in the database.
I'm not sure I've reproduced it exactly, but I ended up with (updated)
from unidecode import unidecode
def unicase_compare(x, y):
x_ = unidecode(x).lower()
y_ = unidecode(y).lower()
return 1 if x_ > y_ else -1 if x_ < y_ else 0
connection.create_collation("unicase", unicase_compare)
here's the rust library for the actual unicase collation https://github.com/seanmonstar/unicase
woops, the example collation is busted. Didn't realize it was supposed to return 1, 0, -1
updated the above comment with a version that appears to work