Skip to content

Commit 81f6d97

Browse files
authored
HCK-14758: Fix settings of clusteringKey (#129)
* HCK-14758: Fix settings of clusteringKey * HCK-14759: Fix
1 parent c853b8b commit 81f6d97

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

  • forward_engineering/alterScript/alterScriptHelpers

forward_engineering/alterScript/alterScriptHelpers/common.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
1+
const { isEqual } = require('lodash');
12
const { escapeQuotes, getTimestamp, getName } = require('../../helpers/utils');
2-
const _ = require('lodash');
33

44
const getCompMod = containerData => containerData.role?.compMod ?? {};
55

6-
const checkCompModEqual = ({ new: newItem, old: oldItem } = {}) => _.isEqual(newItem, oldItem);
6+
const checkCompModEqual = ({ new: newItem, old: oldItem } = {}) => isEqual(newItem, oldItem);
77

88
const setEntityKeys = ({ idToNameHashTable, idToActivatedHashTable, entity }) => {
9+
const setKeyArray = obj =>
10+
Array.isArray(obj)
11+
? obj.map(item => ({
12+
...item,
13+
name: idToNameHashTable[item.keyId],
14+
isActivated: idToActivatedHashTable[item.keyId],
15+
}))
16+
: [];
17+
918
return {
1019
...entity,
11-
clusteringKey:
12-
entity.clusteringKey?.map(key => ({
13-
...key,
14-
name: idToNameHashTable[key.keyId],
15-
isActivated: idToActivatedHashTable[key.keyId],
16-
})) || [],
17-
timeUnitpartitionKey:
18-
entity.timeUnitpartitionKey?.map(key => ({
19-
...key,
20-
name: idToNameHashTable[key.keyId],
21-
isActivated: idToActivatedHashTable[key.keyId],
22-
})) || [],
20+
clusteringKey: setKeyArray(entity.clusteringKey),
21+
timeUnitpartitionKey: setKeyArray(entity.timeUnitpartitionKey),
2322
rangeOptions: [
2423
{
2524
...(entity.rangeOptions ?? {}),
26-
rangePartitionKey:
27-
entity.rangeOptions?.rangePartitionKey?.map(key => ({
28-
...key,
29-
name: idToNameHashTable[key.keyId],
30-
isActivated: idToActivatedHashTable[key.keyId],
31-
})) || [],
25+
rangePartitionKey: setKeyArray(entity.rangeOptions?.rangePartitionKey),
3226
},
3327
],
3428
};
@@ -40,9 +34,9 @@ const getModifyOptions = ({ jsonSchema, app, options }) => {
4034
const optionsToUpdate = [];
4135

4236
Object.entries(options).forEach(([customOptionName, columnOptionName]) => {
43-
const { new: newOptionValue, old: oldOptionValue } = jsonSchema.role.compMod[customOptionName] || {};
37+
const { new: newOptionValue, old: oldOptionValue } = jsonSchema.compMod[customOptionName] || {};
4438

45-
if (!_.isEqual(newOptionValue, oldOptionValue)) {
39+
if (!isEqual(newOptionValue, oldOptionValue)) {
4640
switch (customOptionName) {
4741
case 'businessName': {
4842
const name = getName(jsonSchema.role);

0 commit comments

Comments
 (0)