From 133f6a11ec523157e1ed54fa5e965b1cb2d53477 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 6 Mar 2021 21:42:35 -0500 Subject: [PATCH] SearchKit - Fix removing all related fields from SELECT when removing a JOIN --- ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js b/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js index a74fdf9acaaa..6a48f8167cda 100644 --- a/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js +++ b/ext/search/ang/crmSearchAdmin/crmSearchAdmin.component.js @@ -264,7 +264,8 @@ var alias = searchMeta.getJoin(ctrl.savedSearch.api_params.join[index][0]).alias; ctrl.clearParam('join', index); _.remove(ctrl.savedSearch.api_params.select, function(item) { - return item.indexOf(alias + '.') === 0; + var pattern = new RegExp('\\b' + alias + '\\.'); + return pattern.test(item.split(' AS ')[0]); }); _.remove(ctrl.savedSearch.api_params.where, function(clause) { return clauseUsesJoin(clause, alias);