From 0fa078f3aa406c35e276ba63543d90ffcb852604 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 30 Mar 2023 13:17:32 +0530 Subject: [PATCH] fix: validate formula on column create/update Signed-off-by: Pranav C --- .../nocodb/src/lib/services/column.svc.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/services/column.svc.ts b/packages/nocodb/src/lib/services/column.svc.ts index b3f35160c6..4ff0a6ea10 100644 --- a/packages/nocodb/src/lib/services/column.svc.ts +++ b/packages/nocodb/src/lib/services/column.svc.ts @@ -129,7 +129,16 @@ export async function columnUpdate(param: { try { // test the query to see if it is valid in db level const dbDriver = await NcConnectionMgrv2.get(base); - await formulaQueryBuilderv2(colBody.formula, null, dbDriver, table); + await formulaQueryBuilderv2( + colBody.formula, + null, + dbDriver, + table, + null, + {}, + null, + true + ); } catch (e) { console.error(e); NcError.badRequest('Invalid Formula'); @@ -934,7 +943,16 @@ export async function columnAdd(param: { try { // test the query to see if it is valid in db level const dbDriver = await NcConnectionMgrv2.get(base); - await formulaQueryBuilderv2(colBody.formula, null, dbDriver, table); + await formulaQueryBuilderv2( + colBody.formula, + null, + dbDriver, + table, + null, + {}, + null, + true + ); } catch (e) { console.error(e); NcError.badRequest('Invalid Formula');