Skip to content

Commit

Permalink
#1177: turn field add/update check case insensitive and remove redund…
Browse files Browse the repository at this point in the history
…ant caching

addresses issue for field names that have changes in letter casing
  • Loading branch information
JoernBerkefeld committed Sep 11, 2024
1 parent 5c12146 commit dffd7d0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/DataExtension.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/DataExtensionField.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions lib/metadataTypes/DataExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ class DataExtension extends MetadataType {
* @returns {Promise.<MetadataTypeMap>} keyField => metadata map
*/
static async upsert(metadataMap, deployDir) {
// get existing DE-fields for DE-keys in deployment package to properly handle add/update/delete of fields
// we need to use IN here because it would fail otherwise if we try to deploy too many DEs at the same time
/** @type {SoapRequestParams} */
const fieldOptions = {
filter: {
leftOperand: 'DataExtension.CustomerKey',
operator: 'IN',
rightOperand: Object.keys(metadataMap),
},
};
Util.logger.info(` - Caching dependent Metadata: dataExtensionField`);
await this.#attachFields(metadataMap, fieldOptions);

/** @type {object[]} */
const metadataToCreate = [];
/** @type {object[]} */
Expand Down
7 changes: 5 additions & 2 deletions lib/metadataTypes/DataExtensionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ class DataExtensionField extends MetadataType {
const existingFieldByName = {};

for (const key of Object.keys(fieldsObj)) {
existingFieldByName[fieldsObj[key].Name] = fieldsObj[key];
// make sure we stringify the name in case it looked numeric and then lowercase it for easy comparison as the server is comparing field names case-insensitive
existingFieldByName[(fieldsObj[key].Name + '').toLowerCase()] = fieldsObj[key];
}
Util.logger.debug('existingFieldByName:');
Util.logger.debug(JSON.stringify(existingFieldByName));
for (let i = deployColumns.length - 1; i >= 0; i--) {
const item = deployColumns[i];
const itemOld = existingFieldByName[item.Name];
const itemOld = existingFieldByName[(item.Name + '').toLowerCase()];
if (itemOld) {
// field is getting updated ---

Expand Down
8 changes: 4 additions & 4 deletions test/general.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
14,
13,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -632,7 +632,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
15,
14,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -697,7 +697,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
12,
11,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -2251,7 +2251,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
14,
13,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down
6 changes: 3 additions & 3 deletions test/type.dataExtension.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('type: dataExtension', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
11,
10,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('type: dataExtension', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
8,
7,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('type: dataExtension', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
12,
11,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down

0 comments on commit dffd7d0

Please sign in to comment.