From 224f57440a0fb2bac795aa622b36e07702c161dd Mon Sep 17 00:00:00 2001 From: Vinicius Mesel Date: Mon, 11 Dec 2023 16:01:51 -0300 Subject: [PATCH] Adds escaping for - sign as well (#7) --- target_salesforce_v3/sinks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target_salesforce_v3/sinks.py b/target_salesforce_v3/sinks.py index 48f47f2..53d905a 100644 --- a/target_salesforce_v3/sinks.py +++ b/target_salesforce_v3/sinks.py @@ -746,8 +746,11 @@ def preprocess_record(self, record, context): # Try to find object instance if record.get("Email"): email_to_check = record.get("Email") - if "+" in email_to_check: - email_to_check = email_to_check.replace("+", "\+") + + # Escape special characters on email + for char in ["+", "-"]: + if char in email_to_check: + email_to_check = email_to_check.replace(char, f"\{char}") query = "".join(["FIND {", email_to_check, "} ", f" IN ALL FIELDS RETURNING {object_type}(id)"]) req = self.request_api("GET", "search/", params={"q": query})