Case Insensitive `like`

In CBL 2.0, is there any option to make like match to be case insensitive? If not, is there any Expression function to change the string value of a field to be lower case?

You can add a Collate to your IExpression, like this:

var myQuery = QueryBuilder.Select(SelectResult.Expression(Meta.ID))
.From(myDataBase)
.Where(Expression.Property(“name”).Collate(Collation.Unicode().IgnoreCase(true).IgnoreAccents(true)).Like(Expression.String(“john”)));

I use Collate like this on an OrderBy, haven’t tried it on a Like yet myself.

1 Like

Yes , there is . You can read about it in the examples in this blog

 let searchQuery = QueryBuilder
        .select(SelectResult.expression(Meta.id),
                SelectResult.expression(Expression.property("country")),
                SelectResult.expression(Expression.property("name")))
        .from(DataSource.database(db))
        .where(Expression.property("type").equalTo(Expression.string("landmark"))
            .and(Function.lower(Expression.property("name")).like(Expression.string("royal engineers museum"))))
        .limit(Expression.int(limit))

thanks! this is a great workaround!

good to know about Collate function. thanks!