From 4bcf91fd03fc7e7babdb49d981e4310b233ee3c1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 22 Nov 2023 07:17:55 +0000 Subject: [PATCH] fix: REGEX_EXTRACT - formula function correction --- packages/nc-gui/utils/formulaUtils.ts | 2 +- packages/nocodb/src/db/functionMappings/pg.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/utils/formulaUtils.ts b/packages/nc-gui/utils/formulaUtils.ts index aac7611cf9..abe03d1d19 100644 --- a/packages/nc-gui/utils/formulaUtils.ts +++ b/packages/nc-gui/utils/formulaUtils.ts @@ -482,7 +482,7 @@ const formulas: Record = { rqd: 0, }, }, - description: 'Returns an empty string.', + description: 'Returns a blank value.', syntax: 'BLANK()', examples: ['BLANK()'], }, diff --git a/packages/nocodb/src/db/functionMappings/pg.ts b/packages/nocodb/src/db/functionMappings/pg.ts index 427454d13b..2105f19dcf 100644 --- a/packages/nocodb/src/db/functionMappings/pg.ts +++ b/packages/nocodb/src/db/functionMappings/pg.ts @@ -201,7 +201,9 @@ const pg = { const pattern = (await fn(pt.arguments[1])).builder; return { builder: knex.raw( - `REGEXP_MATCHES(${source}::text, ${pattern}::text) ${colAlias}`, + // use `SUBSTRING` since REGEXP_MATCH returns array value + // `REGEXP_MATCH(${source}::text, ${pattern}::text) ${colAlias}`, + `SUBSTRING(${source}::text from ${pattern}::text) ${colAlias}`, ), }; },