Skip to content

Commit

Permalink
Merge pull request #1694 from Accenture/bug/1177-test-for-addedupdate…
Browse files Browse the repository at this point in the history
…d-fields-faulty-during-update

bug/1177 make field add/update check case insensitive and remove redundant caching
  • Loading branch information
JoernBerkefeld authored Sep 11, 2024
2 parents 5c12146 + 122c70c commit 9076243
Show file tree
Hide file tree
Showing 6 changed files with 13 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
6 changes: 4 additions & 2 deletions lib/metadataTypes/DataExtensionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ 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];
}
for (let i = deployColumns.length - 1; i >= 0; i--) {
const item = deployColumns[i];
const itemOld = existingFieldByName[item.Name];
// 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
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 9076243

Please sign in to comment.