fix(server): use substring matching for person name search (#26903)

This commit is contained in:
okxint
2026-04-01 19:01:54 +05:30
committed by GitHub
parent 2a619d3c10
commit d1e2e8ab4e
4 changed files with 25 additions and 17 deletions
+4 -10
View File
@@ -312,16 +312,10 @@ export class PersonRepository {
return this.db
.selectFrom('person')
.selectAll('person')
.where((eb) =>
eb.and([
eb('person.ownerId', '=', userId),
eb.or([
eb(eb.fn('lower', ['person.name']), 'like', `${personName.toLowerCase()}%`),
eb(eb.fn('lower', ['person.name']), 'like', `% ${personName.toLowerCase()}%`),
]),
]),
)
.limit(1000)
.where('person.ownerId', '=', userId)
.where(() => sql`f_unaccent("person"."name") %>> f_unaccent(${personName})`)
.orderBy(sql`f_unaccent("person"."name") <->>> f_unaccent(${personName})`)
.limit(100)
.$if(!withHidden, (qb) => qb.where('person.isHidden', '=', false))
.execute();
}