From 11957c3eae25be3a73e82fb1f7df7775ccb758c5 Mon Sep 17 00:00:00 2001 From: David Nagy Date: Thu, 18 Jul 2024 14:09:34 +0200 Subject: [PATCH] chore: fix some sql scrubber thingies --- src/scrubbers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scrubbers.ts b/src/scrubbers.ts index 51bd5d0..14aab9f 100644 --- a/src/scrubbers.ts +++ b/src/scrubbers.ts @@ -491,9 +491,9 @@ export const saltedHashSubstringScrubberSQL: SaltedHashSubstringScrubberSQLFn = _assert(params?.initializationVector, 'Initialization vector is missing') _assert(params?.regex, 'Substring or regex is missing') - const substringToReplace = `REGEXP_SUBSTR(${sqlValueToReplace}, ${params.regex})` + const substringToReplace = `COALESCE(REGEXP_SUBSTR(${sqlValueToReplace}, '${params.regex}'), '')` const hashedValue = `SHA2(${substringToReplace} || '${params.initializationVector}', 256)` - const replacedValue = `REGEXP_REPLACE(${sqlValueToReplace}, ${params.regex}, ${hashedValue})` + const replacedValue = `REGEXP_REPLACE(${sqlValueToReplace}, '${params.regex}', ${hashedValue})` return replacedValue }