sqlkata / querybuilder

SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
https://sqlkata.com
MIT License
3.06k stars 499 forks source link

Error on WhereContains #707

Closed joc-luis closed 5 months ago

joc-luis commented 5 months ago

When the following query is executed: new Query("Users").Join("Roles", "Roles.Id", "RoleId") .Select("Users.Id", "Users.Nick", "Users.Email", "Roles.Name as Role", "RoleId") .WhereContains("Users.Nick", request.Value) .PaginateAsync<TEntity>(1, 100, cancellationToken: ct)

The result in string is: SELECT "Users"."Id", "Users"."Nick", "Users"."Email", "Roles"."Name" AS "Role", "RoleId" FROM "Users" INNER JOIN "Roles" ON "Roles"."Id" = "RoleId" WHERE "Users"."Nick" ilike '%m%'

For some reason an i is added to the beginning of the like

Revazashvili commented 5 months ago

i guess you're using postgres database, WhereContains takes parameter caseSensitive which is false by default, if it's false compiler generates ILIKE operator otherwise LIKE, so try passing true in caseSensitive parameter.