SaltechSystems / couchbase_lite

Flutter plugin for the Community edition of Couchbase Lite. Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`lower` function support for Expression

igorcafe opened this issue · comments

commented

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...

Hi,

Already exists:

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

commented

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

commented

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