views:

23

answers:

1

I'm querying an SQLite database using NHibernate. Generally, I want to do case insensitive string queries. Recently, I've discovered that although I can insert a row with Cyrillic characters, I can not select it using a case insensitive query. This is what the query looks like:

string foo = "foo";
IList<T> list = session.CreateCriteria(typeof(T)).
    Add(Expression.Eq("Foo", foo).IgnoreCase()).List<T>();

I can, however, select the row using the above query if IgnoreCase() is removed. A naive fix would be to check if list.Count == 0 after the first query, and make a subsequent case sensitive query. The major downside of this approach is that querying for non-existent rows is a reasonably common operation that would now consist of two queries.

The question is, how can I construct a single query that will select from the Foo column that is case insensitive yet will also select rows that contain Cyrillic characters?

+2  A: 

Case insensitive queries by default only work with ASCII characters in SQLite.

See this FAQ: Case-insensitive matching of Unicode characters does not work.

gclj5
Thanks. This describes why it isn't working. It does not describe a potential fix or workaround. Even building with ICU support does not seem to have a general case fix, from what I've been able to find.
anthony
For the LIKE operator, SQLite's ICU extension makes use of language independent case folding, AFAIK. Perhaps some of the examples given here might be helpful: http://www.sqlite.org/cvstrac/fileview?f=sqlite/ext/icu/README.txt
gclj5