Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean empty datetime fields in fallback sink #25

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions target_salesforce_v3/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,13 @@ def preprocess_record(self, record, context):
except MissingObjectInSalesforceError:
self.logger.info("Skipping record, because it was not found on Salesforce.")
return {}

# keep only available fields and that are creatable or updatable
record = {k:v for k,v in record.items() if fields.get(k) and (fields[k]["createable"] or fields[k]["updateable"])}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a boolean and it's False will this still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all values inside fields are dicts and both both createable and updateable are boolean values, so I think it should work if the field is either createable or updateable

# clean empty date fields to avoid salesforce parsing error
record = {k:v for k,v in record.items() if fields[k].get("type") not in ["date", "datetime"] or (fields[k].get("type") in ["date", "datetime"] and v)}

# add object_type
record["object_type"] = object_type

# If lookup_fields dict exist in config use it to check if the record exists in Salesforce
Expand Down
Loading