From 4f4a3d135323727e2cd7bd1cc21ca93e932139e7 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 15 Feb 2024 13:08:41 +0700 Subject: [PATCH] fix search with concat fullname --- src/controllers/PositionController.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 61df770a..fda8bd44 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -855,12 +855,11 @@ export class PositionController extends Controller { .leftJoinAndSelect('posMaster.current_holder', 'current_holder') .leftJoinAndSelect('posMaster.next_holder', 'next_holder') .where(conditions) - // .orWhere('(current_holder.prefix LIKE :keyword OR current_holder.firstName LIKE :keyword OR current_holder.lastName LIKE :keyword)', { keyword: `%${body.keyword}%` }) .orWhere( new Brackets((qb) => { qb.where( body.keyword != null && body.keyword != "" - ? "current_holder.prefix LIKE :keyword OR current_holder.firstName LIKE :keyword OR current_holder.lastName LIKE :keyword OR :keyword LIKE current_holder.prefix OR :keyword LIKE current_holder.firstName OR :keyword LIKE current_holder.lastName" + ? "CONCAT(current_holder.prefix, current_holder.firstName, current_holder.lastName) LIKE :keyword OR :keyword LIKE current_holder.prefix OR :keyword LIKE current_holder.firstName OR :keyword LIKE current_holder.lastName " : "1=1", { keyword: `%${body.keyword}%`,