anthony
anthony

Reputation: 41118

NHibernate, SQLite, and Cyrillic characters: case sensitivity and fallback queries

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?

Upvotes: 0

Views: 1497

Answers (1)

gclj5
gclj5

Reputation: 1956

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

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

Upvotes: 3

Related Questions