diff --git a/forward_engineering/ddlProvider.js b/forward_engineering/ddlProvider.js index 562cfc8..6d2919d 100644 --- a/forward_engineering/ddlProvider.js +++ b/forward_engineering/ddlProvider.js @@ -20,7 +20,7 @@ module.exports = (baseProvider, options, app) => { const { assignTemplates, compareGroupItems } = app.require('@hackolade/ddl-fe-utils'); const { decorateDefault, decorateType, canBeNational, getSign, createGeneratedColumn, canHaveAutoIncrement } = require('./helpers/columnDefinitionHelper')(_, wrap); - const { getTableName, getIndexName, getTableOptions, getPartitions, getViewData, getCharacteristics, escapeQuotes } = + const { getTableName, getTableOptions, getPartitions, getViewData, getCharacteristics, escapeQuotes } = require('./helpers/general')(_, wrap); const { generateConstraintsString, foreignKeysToString, foreignActiveKeysToString, createKeyConstraint } = require('./helpers/constraintsHelper')({ @@ -430,10 +430,7 @@ module.exports = (baseProvider, options, app) => { const wholeStatementCommented = index.isActivated === false || !isParentActivated || allDeactivated; const indexType = index.indexType && _.toUpper(index.indexType) !== 'KEY' ? `${_.toUpper(index.indexType)} ` : ''; - const name = getIndexName({ - name: index.indxName, - schemaName: dbData.databaseName, - }) + const name = wrap(index.indxName || '', '`', '`'); const table = getTableName(tableName, dbData.databaseName); const indexCategory = index.indexCategory ? ` USING ${index.indexCategory}` : ''; let indexOptions = []; diff --git a/forward_engineering/helpers/general.js b/forward_engineering/helpers/general.js index fee0c7e..057c5f2 100644 --- a/forward_engineering/helpers/general.js +++ b/forward_engineering/helpers/general.js @@ -67,38 +67,14 @@ module.exports = (_, wrap) => { NDB: ['KEY_BLOCK_SIZE'], }; - /** - * @param {Object} params - * @param {string} params.name - * @param {string} params.schemaName - * @returns {string} - * */ - const getNamePrefixedWithSchemaName = ({ name, schemaName }) => { + const getTableName = (tableName, schemaName) => { if (schemaName) { - return `\`${schemaName}\`.\`${name}\``; + return `\`${schemaName}\`.\`${tableName}\``; + } else { + return `\`${tableName}\``; } - return `\`${name}\``; - }; - - /** - * @param schemaName {string} - * @param tableName {string} - * @return {string} - * */ - const getTableName = (tableName, schemaName) => { - return getNamePrefixedWithSchemaName({ name: tableName, schemaName }); }; - /** - * @param {Object} params - * @param {string} params.name - * @param {string} params.schemaName - * @returns {string} - */ - const getIndexName = ({ name, schemaName }) => { - return getNamePrefixedWithSchemaName({ name, schemaName }); - } - const getOptionValue = (keyword, value) => { if (['ROW_FORMAT', 'INSERT_METHOD'].includes(keyword)) { if (value) { @@ -347,7 +323,6 @@ module.exports = (_, wrap) => { return { getTableName, - getIndexName, getTableOptions, getPartitions, getViewData,