Skip to content

Commit

Permalink
Merge pull request #720 from jetstreamapp/bug/719
Browse files Browse the repository at this point in the history
Load to multiple records - fix edge case
  • Loading branch information
paustint authored Feb 7, 2024
2 parents b31442f + 56273fa commit f21806c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ export function getDataGraph(
}: { transformedRecord: MapOf<any>; externalIdValue: string | null; recordIdForUpdate: string | null; dependencies: string[] },
header
) => {
const isRelatedField = header.includes('.');
const field = dataset.fieldsByName[header.toLowerCase()];
let value = record[header];
const valueIsNull = isNil(value) || (isString(value) && !value);
Expand All @@ -423,7 +424,7 @@ export function getDataGraph(
} else if (insertNulls) {
transformedRecord[field.name] = null;
}
} else if (dataset.operation === 'UPSERT' && lowercaseExternalId === field.name.toLowerCase()) {
} else if (dataset.operation === 'UPSERT' && !isRelatedField && lowercaseExternalId === field.name.toLowerCase()) {
// External id used for upsert, this needs to be omitted from the record as the value is included in the URL
externalIdValue = value;
} else if (insertNulls || !valueIsNull) {
Expand All @@ -443,7 +444,7 @@ export function getDataGraph(
}

// for updates, we need to know the url to update the record - this could be a relationship id or hard-coded id
if (dataset.operation === 'UPDATE' && field.name.toLowerCase() === 'id') {
if (dataset.operation === 'UPDATE' && !isRelatedField && field.name.toLowerCase() === 'id') {
recordIdForUpdate = transformedRecord[field.name];
}

Expand Down

0 comments on commit f21806c

Please sign in to comment.