Browse Source

fix: validate formula on column create/update

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5379/head
Pranav C 2 years ago
parent
commit
0fa078f3aa
  1. 22
      packages/nocodb/src/lib/services/column.svc.ts

22
packages/nocodb/src/lib/services/column.svc.ts

@ -129,7 +129,16 @@ export async function columnUpdate(param: {
try { try {
// test the query to see if it is valid in db level // test the query to see if it is valid in db level
const dbDriver = await NcConnectionMgrv2.get(base); 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) { } catch (e) {
console.error(e); console.error(e);
NcError.badRequest('Invalid Formula'); NcError.badRequest('Invalid Formula');
@ -934,7 +943,16 @@ export async function columnAdd(param: {
try { try {
// test the query to see if it is valid in db level // test the query to see if it is valid in db level
const dbDriver = await NcConnectionMgrv2.get(base); 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) { } catch (e) {
console.error(e); console.error(e);
NcError.badRequest('Invalid Formula'); NcError.badRequest('Invalid Formula');

Loading…
Cancel
Save