couchbase_lite icon indicating copy to clipboard operation
couchbase_lite copied to clipboard

`lower` function support for Expression

Open igorcafe opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. I'm trying to query users by name like %something%.

var query = QueryBuilder.select([SelectResult.all()])
    .from(CouchbaseHelper.databaseName!)
    .where(Expression.property("name")
            .like(Expression.string("%test%"))));

It works, but it is case sensitive. So I searched in couchbase forum how to do a case insensitive query and found this:

SELECT * FROM contacts WHERE lower(last_name) = “smith”;

Describe the solution you'd like I think the solution would be something like:

where(Expression.lower(Expression.property("name"))
            .like(Expression.string("%test%")));

Describe alternatives you've considered I don't have other ideas. Feel free to suggest something...

igorcafe avatar Jun 24 '22 16:06 igorcafe

Hi,

Already exists:

(Functions.lower(Expression.property("description")).like(Expression.string("%${searchTerm.toLowerCase()}%")))

arnzuk avatar Jul 27 '22 18:07 arnzuk

@arnzuk for some reason it is not working... it only works when the case matches exactly. image

igorcafe avatar May 22 '23 16:05 igorcafe

Is there any way of using raw queries? Just to make sure

igorcafe avatar May 22 '23 16:05 igorcafe