stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.59k stars 1.55k forks source link

Like does not work with Russian symbols? (ICU support) #1025

Open Wolfaks opened 3 years ago

Wolfaks commented 3 years ago

Hello. I use like with lowercaseString and Russian symbols but LOWER doesn't convert them to lowercase in the query. I tried to create my own function but it didn't work for me. How to solve this problem? Thanks.

// in name value: ПРИВЕТ from database let search_name = "Привет" user.filter(name.lowercaseString.like("%" + search_name.lowercased() + "%"))

Wolfaks commented 3 years ago

Having studied the documentation of SQLite, I learned that you need to connect the ICU library. How can this be done in this plugin? Thanks.

jberkel commented 2 years ago

You need to use it with a version of SQLite compiled with SQLITE_ENABLE_ICU. As far as I can tell there's no out of the box way of doing this, and the sqlite3 pod doesn't seem to provide this.

There is an open ticket for it though, see https://github.com/clemensg/sqlite3pod/issues/13

Another option would be to do the lower case transformation on the “Swift” side, and pass it through to the query (not always possible, but would work for the simple example you gave above).

clemensg commented 2 years ago

Hi, just wanted to let you know that I added a branch with experimental support for ICU. I could only test it on macOS 12.1 so far, so it would be great if you could try it out and report back. You can reference the branch like this pod 'sqlite3', inhibit_warnings: true, subspecs: ['icu'], git: 'https://github.com/clemensg/sqlite3pod.git', branch: 'icu'

jberkel commented 2 years ago

@clemensg great, thanks for the notification, will try it out!