Skip to content
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
38 changes: 16 additions & 22 deletions forward_engineering/alterScript/alterScriptHelpers/common.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
const { isEqual } = require('lodash');
const { escapeQuotes, getTimestamp, getName } = require('../../helpers/utils');
const _ = require('lodash');

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

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

const setEntityKeys = ({ idToNameHashTable, idToActivatedHashTable, entity }) => {
const setKeyArray = obj =>
Array.isArray(obj)
? obj.map(item => ({
...item,
name: idToNameHashTable[item.keyId],
isActivated: idToActivatedHashTable[item.keyId],
}))
: [];

return {
...entity,
clusteringKey:
entity.clusteringKey?.map(key => ({
...key,
name: idToNameHashTable[key.keyId],
isActivated: idToActivatedHashTable[key.keyId],
})) || [],
timeUnitpartitionKey:
entity.timeUnitpartitionKey?.map(key => ({
...key,
name: idToNameHashTable[key.keyId],
isActivated: idToActivatedHashTable[key.keyId],
})) || [],
clusteringKey: setKeyArray(entity.clusteringKey),
timeUnitpartitionKey: setKeyArray(entity.timeUnitpartitionKey),
rangeOptions: [
{
...(entity.rangeOptions ?? {}),
rangePartitionKey:
entity.rangeOptions?.rangePartitionKey?.map(key => ({
...key,
name: idToNameHashTable[key.keyId],
isActivated: idToActivatedHashTable[key.keyId],
})) || [],
rangePartitionKey: setKeyArray(entity.rangeOptions?.rangePartitionKey),
},
],
};
Expand All @@ -40,9 +34,9 @@ const getModifyOptions = ({ jsonSchema, app, options }) => {
const optionsToUpdate = [];

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

if (!_.isEqual(newOptionValue, oldOptionValue)) {
if (!isEqual(newOptionValue, oldOptionValue)) {
switch (customOptionName) {
case 'businessName': {
const name = getName(jsonSchema.role);
Expand Down