Couchbase lite 2.0., DB22, like became case sensitive?

Hi,

Since I upgraded from db21 to the version db22, in xamarin forms, c#, I had some queries that didn’t work anymore.

This querries include some “like” filters. Here is a working exemple (for the db19 version) :

IQuery query = Query.Select(SelectResult.All())
			.From(DataSource.Database(_dataBaseGetter.Get()))
			.Where
			(
				Expression.Property("table").EqualTo("programme")
				.And(Expression.Property("localite").Like($"{critere}%"))
			)
			.OrderBy(Ordering.Property("localite").Ascending())
			.Limit(limit);

When I executed this query with the critere = “me” (lowercase), I obtained 2 docs, with localite = “MELUN” (upercase)

With the db22, I apply the basic changes like that :

			IQuery query = QueryBuilder.Select(SelectResult.All())
			.From(DataSource.Database(_dataBaseGetter.Get()))
			.Where
			(
					Expression.Property("table").EqualTo(Expression.String("programme"))
				.And(Expression.Property("localite").Like(Expression.String($"{critere}%")))
			)
			.OrderBy(Ordering.Property("localite").Ascending())
			.Limit(Expression.Int(limit))
			;

That didn’t work anymore, with the same critere = “me”, I obtained 0 result

After some reserches, I finaly wrote the query like that :

			IQuery query = QueryBuilder.Select(SelectResult.All())
			.From(DataSource.Database(_dataBaseGetter.Get()))
			.Where
			(
					Expression.Property("table").EqualTo(Expression.String("programme"))
				.And(Function.Upper(Expression.Property("localite")).Like(Expression.String($"{critere.ToUpper()}%")))
			)
			.OrderBy(Ordering.Property("localite").Ascending())
			.Limit(Expression.Int(limit))
			;

So, I think the db22 introduce some case sensitive patternes that wasn’t in the db21. Can someone confirm that ?

Regards

Steeve

Yes. Pattern matching with like is now case sensitive. This keeps us consistent with our server side querying capability…you can use the Function.Lower to do case insensitive matches.

Check out the “pattern matching” section here.

1 Like