♻️ use like & LOWER(column) for searching with query

This commit is contained in:
Fred KISSIE
2026-02-14 04:11:27 +01:00
parent 1fbcad8787
commit 761a5f1d4c
5 changed files with 96 additions and 62 deletions

View File

@@ -20,9 +20,9 @@ import {
asc,
desc,
eq,
ilike,
inArray,
isNull,
like,
or,
sql,
type SQL
@@ -305,7 +305,14 @@ export async function listClients(
}
if (query) {
conditions.push(or(ilike(clients.name, "%" + query + "%")));
conditions.push(
or(
like(
sql`LOWER(${clients.name})`,
"%" + query.toLowerCase() + "%"
)
)
);
}
const baseQuery = queryClientsBase().where(and(...conditions));

View File

@@ -20,10 +20,10 @@ import {
asc,
desc,
eq,
ilike,
inArray,
isNotNull,
isNull,
like,
or,
sql,
type SQL
@@ -287,8 +287,14 @@ export async function listUserDevices(
if (query) {
conditions.push(
or(
ilike(clients.name, "%" + query + "%"),
ilike(users.email, "%" + query + "%")
like(
sql`LOWER(${clients.name})`,
"%" + query.toLowerCase() + "%"
),
like(
sql`LOWER(${users.email})`,
"%" + query.toLowerCase() + "%"
)
)
);
}