From 021b4d59306371b354b9b46a047385b9d9f24ad8 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 22 Nov 2023 07:17:57 +0000 Subject: [PATCH] refactor: REGEX_MATCH - return 0/1 --- packages/nocodb/src/db/functionMappings/pg.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/db/functionMappings/pg.ts b/packages/nocodb/src/db/functionMappings/pg.ts index b09d11d150..deecfae1fa 100644 --- a/packages/nocodb/src/db/functionMappings/pg.ts +++ b/packages/nocodb/src/db/functionMappings/pg.ts @@ -193,7 +193,9 @@ const pg = { const source = (await fn(pt.arguments[0])).builder; const pattern = (await fn(pt.arguments[1])).builder; return { - builder: knex.raw(`(${source}::TEXT ~ ${pattern}::TEXT) ${colAlias}`), + builder: knex.raw( + `CASE WHEN (${source}::TEXT ~ ${pattern}::TEXT) THEN 1 ELSE 0 END ${colAlias}`, + ), }; }, REGEX_EXTRACT: async ({ fn, knex, pt, colAlias }: MapFnArgs) => {