From a79d4c91cdbb2795183c669fa7bb5608937f8472 Mon Sep 17 00:00:00 2001 From: Serhii Filonenko <91055067+serhii-filonenko@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:04:02 +0200 Subject: [PATCH] HCK-9315: fix adding storage option to table only if defined (#157) --- .../ddlProvider/ddlHelpers/tableHelper.js | 13 +++---------- forward_engineering/ddlProvider/ddlProvider.js | 1 - forward_engineering/ddlProvider/templates.js | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/forward_engineering/ddlProvider/ddlHelpers/tableHelper.js b/forward_engineering/ddlProvider/ddlHelpers/tableHelper.js index 88c850e..dd67693 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/tableHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/tableHelper.js @@ -1,12 +1,5 @@ const _ = require('lodash'); -module.exports = ({ - _, - getColumnsList, - checkAllKeysDeactivated, - commentIfDeactivated, - prepareName, - assignTemplates, -}) => { +module.exports = ({ getColumnsList, checkAllKeysDeactivated, commentIfDeactivated, prepareName, assignTemplates }) => { const { getOptionsString } = require('./constraintHelper')({ _, prepareName }); const getTableType = ({ @@ -49,7 +42,7 @@ module.exports = ({ .filter(Boolean) .join(''); - return _.trim(statements) ? ` ${_.trim(statements)}` : ''; + return _.trim(statements) ? `\n ${_.trim(statements)}` : ''; }; const getBlockChainClause = @@ -78,7 +71,7 @@ module.exports = ({ const getStorage = textTableProperties => ({ organization, tablespace, logging }) => { - if (_.includes(textTableProperties, 'TABLESPACE')) { + if (!organization || _.includes(textTableProperties, 'TABLESPACE')) { return ''; } diff --git a/forward_engineering/ddlProvider/ddlProvider.js b/forward_engineering/ddlProvider/ddlProvider.js index 8aa4af7..b67ad23 100644 --- a/forward_engineering/ddlProvider/ddlProvider.js +++ b/forward_engineering/ddlProvider/ddlProvider.js @@ -69,7 +69,6 @@ module.exports = (baseProvider, options, app) => { createKeyConstraint, customPropertiesForForeignKey, } = require('./ddlHelpers/tableHelper')({ - _, checkAllKeysDeactivated, getColumnsList, commentIfDeactivated, diff --git a/forward_engineering/ddlProvider/templates.js b/forward_engineering/ddlProvider/templates.js index 51cf6ae..8ce77e6 100644 --- a/forward_engineering/ddlProvider/templates.js +++ b/forward_engineering/ddlProvider/templates.js @@ -3,7 +3,7 @@ module.exports = { comment: '\nCOMMENT ON ${object} ${objectName} IS ${comment};\n', - createTable: 'CREATE${tableType} TABLE${ifNotExists} ${name}${tableProps}\n${options}', + createTable: 'CREATE${tableType} TABLE${ifNotExists} ${name}${tableProps}${options}', createTableProps: '${columnDefinitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}',