Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/axios-1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bigorn0 authored Dec 10, 2024
2 parents b172e8d + d29f95e commit 824aa4a
Show file tree
Hide file tree
Showing 28 changed files with 1,523 additions and 740 deletions.
53 changes: 53 additions & 0 deletions adapter/0.2.13.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright © 2016-2024 by IntegrIT S.A. dba Hackolade. All rights reserved.
*
* The copyright to the computer software herein is the property of IntegrIT S.A.
* The software may be used and/or copied only with the written permission of
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
* the agreement/contract under which the software has been supplied.
*
* {
* "add": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "delete": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "modify": {
* "entity": [
* {
* "from": { <properties that identify record> },
* "to": { <properties that need to be changed> }
* }
* ],
* "container": [],
* "model": [],
* "view": [],
* "field": []
* },
* }
*/
{
"modify": {
"view": [
{
"from": {},
"to": {
"viewOn": ""
}
}
]
}
}
58 changes: 58 additions & 0 deletions adapter/0.2.8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright © 2016-2018 by IntegrIT S.A. dba Hackolade. All rights reserved.
*
* The copyright to the computer software herein is the property of IntegrIT S.A.
* The software may be used and/or copied only with the written permission of
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
* the agreement/contract under which the software has been supplied.
*
* {
* "add": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "delete": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "modify": {
* "entity": [
* {
* "from": { <properties that identify record> },
* "to": { <properties that need to be changed> }
* }
* ],
* "container": [],
* "model": [],
* "view": [],
* "field": []
* },
* }
*/
{
"add": {},
"modify": {
"field": [
{
"from": {
"primaryKey": true,
"unique": true
},
"to": {
"unique": false
}
}
]
},
"delete": {}
}
2 changes: 1 addition & 1 deletion forward_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = {
await getExternalBrowserUrl(connectionInfo, logger, callback, app);
} else {
const client = await connect(connectionInfo, logger, () => {}, app);
await logDatabaseVersion(client, logger);
await logDatabaseVersion({ client, logger });
}
callback(null);
} catch (error) {
Expand Down
16 changes: 8 additions & 8 deletions forward_engineering/configs/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ module.exports = {
dropType: 'DROP TYPE IF EXISTS ${name}${terminator}',

createSchemaComment:
"EXEC sp_addextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}${terminator}",
"EXEC sp_addextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}${terminator}",

createTableComment:
"EXEC sp_addextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}, 'table', ${tableName}${terminator}",
"EXEC sp_addextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}, 'table', ${tableName}${terminator}",

createColumnComment:
"EXEC sp_addextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}, 'table', ${tableName}, 'column', ${columnName}${terminator}",
"EXEC sp_addextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}, 'table', ${tableName}, 'column', ${columnName}${terminator}",

createViewComment:
"EXEC sp_addextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}, 'view', ${viewName}${terminator}",
"EXEC sp_addextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}, 'view', ${viewName}${terminator}",

dropSchemaComment: "EXEC sp_dropextendedproperty 'MS_Description', 'schema', ${schemaName}${terminator}",

Expand All @@ -114,14 +114,14 @@ module.exports = {
"EXEC sp_dropextendedproperty 'MS_Description', 'schema', ${schemaName}, 'view', ${viewName}${terminator}",

updateSchemaComment:
"EXEC sp_updateextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}${terminator}",
"EXEC sp_updateextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}${terminator}",

updateTableComment:
"EXEC sp_updateextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}, 'table', ${tableName}${terminator}",
"EXEC sp_updateextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}, 'table', ${tableName}${terminator}",

updateColumnComment:
"EXEC sp_updateextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}, 'table', ${tableName}, 'column', ${columnName}${terminator}",
"EXEC sp_updateextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}, 'table', ${tableName}, 'column', ${columnName}${terminator}",

updateViewComment:
"EXEC sp_updateextendedproperty 'MS_Description', '${value}', 'schema', ${schemaName}, 'view', ${viewName}${terminator}",
"EXEC sp_updateextendedproperty 'MS_Description', N'${value}', 'schema', ${schemaName}, 'view', ${viewName}${terminator}",
};
35 changes: 24 additions & 11 deletions forward_engineering/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const defaultTypes = require('./configs/defaultTypes');
const types = require('./configs/types');
const templates = require('./configs/templates');
const { commentIfDeactivated } = require('./helpers/commentIfDeactivated');
const { joinActivatedAndDeactivatedStatements } = require('./utils/joinActivatedAndDeactivatedStatements');

module.exports = (baseProvider, options, app) => {
const _ = app.require('lodash');
Expand Down Expand Up @@ -39,7 +40,7 @@ module.exports = (baseProvider, options, app) => {
const { wrapIfNotExistSchema, wrapIfNotExistDatabase, wrapIfNotExistTable, wrapIfNotExistView } =
require('./helpers/ifNotExistStatementHelper')(app);
const { getPartitionedTables, getCreateViewData } = require('./helpers/viewHelper')(app);
const { getFullTableName } = require('./utils/general')(_);
const { getFullTableName, escapeSpecialCharacters } = require('./utils/general')(_);

const terminator = getTerminator(options);

Expand Down Expand Up @@ -137,9 +138,10 @@ module.exports = (baseProvider, options, app) => {
const dividedForeignKeys = divideIntoActivatedAndDeactivated(foreignKeyConstraints, key => key.statement);
const foreignKeyConstraintsString = generateConstraintsString(dividedForeignKeys, isActivated);
const tableAndColumnCommentsSeparator = tableComment ? '\n\n' : '';
const columnStatements = joinActivatedAndDeactivatedStatements({ statements: columns, indent: '\n\t' });
const tableStatement = assignTemplates(templates.createTable, {
name: tableName,
column_definitions: columns.join(',\n\t'),
column_definitions: columnStatements,
temporalTableTime: temporalTableTimeStatement,
checkConstraints: checkConstraints.length ? ',\n\t' + checkConstraints.join(',\n\t') : '',
foreignKeyConstraints: foreignKeyConstraintsString,
Expand Down Expand Up @@ -202,7 +204,7 @@ module.exports = (baseProvider, options, app) => {
columnDefinition.isHidden,
);

return assignTemplates(templates.columnDefinition, {
const statement = assignTemplates(templates.columnDefinition, {
name: columnDefinition.name,
type: decorateType(type, columnDefinition),
primary_key: primaryKey + unique,
Expand All @@ -215,6 +217,8 @@ module.exports = (baseProvider, options, app) => {
temporalTableTime,
...identityContainer,
});

return commentIfDeactivated(statement, { isActivated: columnDefinition.isActivated });
},

createIndex(tableName, index, dbData, isParentActivated = true) {
Expand Down Expand Up @@ -769,7 +773,7 @@ module.exports = (baseProvider, options, app) => {

createSchemaComment({ schemaName, comment, customTerminator }) {
return assignTemplates(templates.createSchemaComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
terminator: customTerminator ?? terminator,
});
Expand All @@ -779,8 +783,9 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName) {
return '';
}

return assignTemplates(templates.createTableComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
tableName: wrapInBrackets(tableName),
terminator: customTerminator ?? terminator,
Expand All @@ -791,8 +796,9 @@ module.exports = (baseProvider, options, app) => {
if (!tableName || !columnName) {
return '';
}

return assignTemplates(templates.createColumnComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
tableName: wrapInBrackets(tableName),
columnName: wrapInBrackets(columnName),
Expand All @@ -804,8 +810,9 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName) {
return '';
}

return assignTemplates(templates.createViewComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
viewName: wrapInBrackets(viewName),
terminator: customTerminator ?? terminator,
Expand All @@ -823,6 +830,7 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName) {
return '';
}

return assignTemplates(templates.dropTableComment, {
schemaName: wrapInBrackets(schemaName),
tableName: wrapInBrackets(tableName),
Expand All @@ -834,6 +842,7 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName || !tableName) {
return '';
}

return assignTemplates(templates.dropColumnComment, {
schemaName: wrapInBrackets(schemaName),
tableName: wrapInBrackets(tableName),
Expand All @@ -846,6 +855,7 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName) {
return '';
}

return assignTemplates(templates.dropViewComment, {
schemaName: wrapInBrackets(schemaName),
viewName: wrapInBrackets(viewName),
Expand All @@ -855,7 +865,7 @@ module.exports = (baseProvider, options, app) => {

updateSchemaComment({ schemaName, comment, customTerminator }) {
return assignTemplates(templates.updateSchemaComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
terminator: customTerminator ?? terminator,
});
Expand All @@ -865,8 +875,9 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName) {
return '';
}

return assignTemplates(templates.updateTableComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
tableName: wrapInBrackets(tableName),
terminator: customTerminator ?? terminator,
Expand All @@ -877,8 +888,9 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName || !tableName) {
return '';
}

return assignTemplates(templates.updateColumnComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
tableName: wrapInBrackets(tableName),
columnName: wrapInBrackets(columnName),
Expand All @@ -890,8 +902,9 @@ module.exports = (baseProvider, options, app) => {
if (!schemaName) {
return '';
}

return assignTemplates(templates.updateViewComment, {
value: comment,
value: escapeSpecialCharacters(comment),
schemaName: wrapInBrackets(schemaName),
viewName: wrapInBrackets(viewName),
terminator: customTerminator ?? terminator,
Expand Down
37 changes: 35 additions & 2 deletions forward_engineering/helpers/alterScriptHelpers/alterViewHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,29 @@ module.exports = (app, options) => {
const { AlterScriptDto } = require('./types/AlterScriptDto');

const getAddViewScriptDto = view => {
const viewName = getTableName(view.code || view.name, view?.role?.compMod?.keyspaceName);
const viewSchema = { ...view, ...(view.role ?? {}) };
const idToNameHashTable = generateRefToNameHashTable(viewSchema);
const idToActivatedHashTable = generateRefToActivatedHashTable(viewSchema);
const schemaData = { schemaName: viewSchema.compMod.keyspaceName };

const viewData = {
name: viewSchema.code || viewSchema.name,
keys: getKeys(viewSchema, viewSchema.compMod?.collectionData?.collectionRefsDefinitionsMap ?? {}),
schemaData: { schemaName: viewSchema.compMod.keyspaceName },
schemaData,
};
const hydratedView = ddlProvider.hydrateView({ viewData, entityData: [view] });

return AlterScriptDto.getInstance([ddlProvider.createView(hydratedView, {}, view.isActivated)], true, false);
const viewScript = AlterScriptDto.getInstance(
[ddlProvider.createView(hydratedView, {}, view.isActivated)],
true,
false,
);
const indexesSCripts = (viewSchema.Indxs || [])
.map(hydrateIndex({ idToNameHashTable, idToActivatedHashTable, schemaData }))
.map(index => AlterScriptDto.getInstance([ddlProvider.createViewIndex(viewName, index)], true, false));

return [viewScript, ...indexesSCripts].filter(Boolean);
};

const getDeleteViewScriptDto = view => {
Expand Down Expand Up @@ -178,6 +191,26 @@ module.exports = (app, options) => {
.filter(Boolean);
};

const generateRefToNameHashTable = view => {
const refToNameHashTable = {};

mapProperties(view, (propertyName, schema) => {
refToNameHashTable[schema.ref] = propertyName;
});

return refToNameHashTable;
};

const generateRefToActivatedHashTable = view => {
const refToActivatedHashTable = {};

mapProperties(view, (propertyName, schema) => {
refToActivatedHashTable[schema.ref] = schema.isActivated;
});

return refToActivatedHashTable;
};

return {
getAddViewScriptDto,
getDeleteViewScriptDto,
Expand Down
Loading

0 comments on commit 824aa4a

Please sign in to comment.