From 8b7941a7dc23cf1cfde7d15486ddc78ee8cba260 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sun, 10 Apr 2022 16:50:26 +0300 Subject: [PATCH 1/2] fix: add date and URL to formulaQueryBuilder Signed-off-by: mertmit --- .../sql/formulav2/formulaQueryBuilderv2.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts index 55cac2ffee..632b32f33f 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts @@ -564,6 +564,41 @@ export default async function formulaQueryBuilderv2( } } break; + case 'DATEADD': + if (pt.arguments[1].value) { + pt.callee.name = 'DATE_ADD'; + return fn(pt, alias, prevBinaryOp); + } else if (pt.arguments[1].operator == '-') { + pt.callee.name = 'DATE_SUB'; + return fn(pt, alias, prevBinaryOp); + } + break; + case 'URL': + return fn( + { + type: 'CallExpression', + arguments: [ + { + type: 'Literal', + value: 'URI::(', + raw: '"URI::("' + }, + pt.arguments[0], + { + type: 'Literal', + value: ')', + raw: '")"' + } + ], + callee: { + type: 'Identifier', + name: 'CONCAT' + } + }, + alias, + prevBinaryOp + ); + break; default: { const res = mapFunctionName({ From 66e414d8591bf1c91c49d72799849275453ef8a7 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sun, 10 Apr 2022 16:50:32 +0300 Subject: [PATCH 2/2] fix: URL parsing on UI Signed-off-by: mertmit --- .../spreadsheet/components/virtualCell/formulaCell.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue index 0d27545f3f..b49dab2551 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue @@ -25,12 +25,13 @@ export default { const rawText = this.row[this.column.title].toString() let found = false - const out = rawText.match(/URI::\((.*?)\)/g, (_, url) => { + const out = rawText.replace(/URI::\((.*?)\)/g, (_, url) => { found = true const a = document.createElement('a') a.textContent = url a.setAttribute('href', url) - return a.innerHTML + a.setAttribute('target', '_blank') + return a.outerHTML }) return found && out