diff --git a/forward_engineering/alterScript/alterScriptHelpers/alterViewHelper.js b/forward_engineering/alterScript/alterScriptHelpers/alterViewHelper.js index 95ffadc..28536f9 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/alterViewHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/alterViewHelper.js @@ -88,7 +88,7 @@ const hydrateAlterView = _ => view => { * */ const getAddViewsScripts = (provider, _) => view => { const hydratedView = hydrateView(_)(view); - const script = provider.createView({ _, ...hydratedView }); + const script = provider.createView(hydratedView); return { isActivated: true, @@ -137,7 +137,7 @@ const getModifyViewsScripts = (provider, _, dbVersion) => view => { } const dropViewScript = provider.dropView(viewName); const hydratedView = hydrateView(_)(view); - const addViewScript = provider.createView({ _, ...hydratedView }); + const addViewScript = provider.createView(hydratedView); const dropViewScriptDto = AlterScriptDto.getInstance([dropViewScript], true, true); const addViewScriptDto = AlterScriptDto.getInstance([addViewScript], true, false); diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 44db3e2..0d974b4 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -258,7 +258,6 @@ module.exports = { * */ generateViewScript(data, logger, callback, app) { try { - const _ = app.require('lodash'); const provider = require('./ddlProvider/ddlProvider')(app); const viewSchema = JSON.parse(data.jsonSchema || '{}'); const dbVersion = data.modelData[0].dbVersion; @@ -268,7 +267,6 @@ module.exports = { const databaseStatement = getDatabaseStatement(data.containerData, isUnityCatalogSupports, dbVersion); const script = provider.createView({ - _, schema: viewSchema, viewData: data.viewData, containerData: data.containerData, diff --git a/forward_engineering/ddlProvider/ddlProvider.js b/forward_engineering/ddlProvider/ddlProvider.js index a686ee5..b76515e 100644 --- a/forward_engineering/ddlProvider/ddlProvider.js +++ b/forward_engineering/ddlProvider/ddlProvider.js @@ -7,6 +7,7 @@ const { getContainerName, getEntityData, getEntityProperties, + wrapInBrackets, } = require('../utils/general'); const { getViewTagsStatement } = require('../helpers/unityTagsHelper'); const { getTablePropertiesClause } = require('../helpers/tableHelper'); @@ -22,7 +23,7 @@ module.exports = app => { }, createView(data) { - const { _, schema, viewData, containerData, collectionRefsDefinitionsMap } = data; + const { schema, viewData, containerData, collectionRefsDefinitionsMap } = data; const columns = schema.properties || {}; const view = _.first(viewData) || {}; @@ -51,20 +52,22 @@ module.exports = app => { temporary: isTemporary ? ' TEMPORARY' : '', ifNotExists: ifNotExists ? ' IF NOT EXISTS' : '', name, - columnList: view.columnList ? `\n(${view.columnList})` : viewHelper.getDefaultColumnList(columns), + columnList: view.columnList + ? `${wrapInBrackets(view.columnList)}` + : viewHelper.getDefaultColumnList(columns), schemaBinding: '', comment: viewHelper.getCommentStatement(schema.description), tablePropertyStatements: tableProperties.length - ? `\nTBLPROPERTIES (${getTablePropertiesClause(_)(tableProperties)})` + ? `TBLPROPERTIES (${getTablePropertiesClause(_)(tableProperties)})` : '', query: schema.selectStatement - ? `\nAS ${schema.selectStatement}` + ? `AS ${schema.selectStatement}` : viewHelper.getTableSelectStatement({ _, collectionRefsDefinitionsMap, columns, }), - viewUnityTagsStatements: viewUnityTagsStatements ? `\n${viewUnityTagsStatements};` : '', + viewUnityTagsStatements: viewUnityTagsStatements ? `${viewUnityTagsStatements};` : '', }); }, diff --git a/forward_engineering/helpers/feScriptBuilder.js b/forward_engineering/helpers/feScriptBuilder.js index af31718..8b7ea13 100644 --- a/forward_engineering/helpers/feScriptBuilder.js +++ b/forward_engineering/helpers/feScriptBuilder.js @@ -137,7 +137,6 @@ const getContainerLevelViewScriptDtos = (data, provider, _) => { const viewSchema = JSON.parse(data.jsonSchema[viewId] || '{}'); const viewData = data.viewData[viewId]; const viewScript = provider.createView({ - _, schema: viewSchema, viewData: viewData, containerData: data.containerData, diff --git a/forward_engineering/helpers/viewHelper.js b/forward_engineering/helpers/viewHelper.js index 95492b9..c52e103 100644 --- a/forward_engineering/helpers/viewHelper.js +++ b/forward_engineering/helpers/viewHelper.js @@ -103,7 +103,7 @@ function getDefaultColumnList(properties) { }) .join(',\n'); - return list ? `\n(${list}\n)` : ''; + return list ? `(${list})` : ''; } function getTableSelectStatement({ _, collectionRefsDefinitionsMap, columns }) { @@ -111,7 +111,7 @@ function getTableSelectStatement({ _, collectionRefsDefinitionsMap, columns }) { const columnsNames = getColumnNames(_)(collectionRefsDefinitionsMap, columns); if (fromStatement && columnsNames?.length) { - return `\nAS SELECT ${joinColumnNames(columnsNames)}\n${fromStatement}`; + return `AS SELECT ${joinColumnNames(columnsNames)}\n${fromStatement}`; } return '';