From 6a7a969518c71f8736ba94af7c742fa37883e120 Mon Sep 17 00:00:00 2001 From: Abdul Rahman Reza Date: Mon, 2 Dec 2024 13:56:11 +0700 Subject: [PATCH] update comm --- src/helpers/common.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/helpers/common.ts b/src/helpers/common.ts index 413990e..c225170 100644 --- a/src/helpers/common.ts +++ b/src/helpers/common.ts @@ -116,7 +116,9 @@ export default class CommonHelper { wtp.push(like); } - whereAttrPre.push('(' + wtp.join(' or ') + ')'); + if (wtp.length > 0) { + whereAttrPre.push('(' + wtp.join(' or ') + ')'); + } if (param.col_any_eq.length > 0) { whereVal['filter_eq'] = filter_any_val; @@ -147,7 +149,10 @@ export default class CommonHelper { wtp.push(like); } - whereAttrPre.push('(' + wtp.join(' or ') + ')'); + if (wtp.length > 0) { + whereAttrPre.push('(' + wtp.join(' or ') + ')'); + } + if (param.col_any_eq.length > 0) { whereVal['filter_eq'] = param.filter.toLowerCase(); @@ -158,8 +163,12 @@ export default class CommonHelper { } } - - const whereAttr = whereAttrPre.join(' and ') + (whereAttrPre.length > 0 && param.additional_where != '' ? ' and ' : '') + param.additional_where; + let whereAttr = ''; + if (whereAttrPre.length > 0) { + whereAttr = whereAttrPre.join(' and ') + (whereAttrPre.length > 0 && param.additional_where != '' ? ' and ' : '') + param.additional_where; + } else { + whereAttr += param.additional_where; + } return { whereAttr, whereVal };