From 69965624457431002f6f39b89ce1d0b274951651 Mon Sep 17 00:00:00 2001 From: Serhii Filonenko <91055067+serhii-filonenko@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:38:00 +0200 Subject: [PATCH] HCK-9136: Remove redundant generation type (#153) * HCK-9136: remove generated type property * HCK-9136: fix column default generation script --- adapter/0.2.22.json | 2 +- .../getColumnDefault.js | 20 ++-- .../field_level/fieldLevelConfig.json | 98 ++----------------- 3 files changed, 15 insertions(+), 105 deletions(-) diff --git a/adapter/0.2.22.json b/adapter/0.2.22.json index dd948a6..b38520b 100644 --- a/adapter/0.2.22.json +++ b/adapter/0.2.22.json @@ -52,7 +52,7 @@ { "generatedDefaultValue": { "asIdentity": true, - "generatedType": "" + "generatedType": "ALWAYS" } } ], diff --git a/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelpers/getColumnDefault.js b/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelpers/getColumnDefault.js index 4f914e2..4572936 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelpers/getColumnDefault.js +++ b/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelpers/getColumnDefault.js @@ -45,19 +45,13 @@ const getOnNullClause = ({ onNull }) => (onNull ? ' ON NULL' : ''); * @returns {string} */ const getGeneratedClause = ({ generatedType, generatedOnNull }) => { - const onNull = getOnNullClause({ onNull: generatedOnNull }); - - switch (generatedType) { - case GENERATED_TYPE.byDefault: { - return ` GENERATED BY DEFAULT${onNull}`; - } - case GENERATED_TYPE.always: { - return ' GENERATED ALWAYS'; - } - default: { - return ''; - } + if (generatedType === GENERATED_TYPE.byDefault) { + const onNull = getOnNullClause({ onNull: generatedOnNull }); + + return ` GENERATED BY DEFAULT${onNull}`; } + + return ' GENERATED ALWAYS'; }; /** @@ -81,7 +75,7 @@ const getColumnDefault = ({ type, default: defaultValue, defaultOnNull, generate const generatedClause = getGeneratedClause({ generatedType, generatedOnNull }); const expressionValue = trim(expression); - if (generatedType && asIdentity && canHaveIdentity({ type }) && !isEmpty(identity)) { + if (asIdentity && canHaveIdentity({ type }) && !isEmpty(identity)) { const identityOptions = getIdentityOptions(identity); return `${generatedClause} AS IDENTITY (${identityOptions})`; diff --git a/properties_pane/field_level/fieldLevelConfig.json b/properties_pane/field_level/fieldLevelConfig.json index 1a062e4..b4205aa 100644 --- a/properties_pane/field_level/fieldLevelConfig.json +++ b/properties_pane/field_level/fieldLevelConfig.json @@ -850,13 +850,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -2673,13 +2666,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -2718,13 +2704,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "As identity", "propertyKeyword": "asIdentity", @@ -2773,18 +2752,18 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS", "BY DEFAULT"], - "defaultValue": "" - }, { "propertyName": "As identity", "propertyKeyword": "asIdentity", "propertyType": "checkbox" }, + { + "propertyName": "Type", + "propertyKeyword": "generatedType", + "propertyType": "select", + "options": ["ALWAYS", "BY DEFAULT"], + "defaultValue": "ALWAYS" + }, { "propertyName": "On null", "propertyKeyword": "generatedOnNull", @@ -4719,13 +4698,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -6303,13 +6275,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -7197,13 +7162,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -8155,13 +8113,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -9442,13 +9393,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -10631,13 +10575,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -11401,13 +11338,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -12345,13 +12275,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression", @@ -12998,13 +12921,6 @@ making sure that you maintain a proper JSON format. "propertyKeyword": "generatedDefaultValue", "propertyType": "block", "structure": [ - { - "propertyName": "Type", - "propertyKeyword": "generatedType", - "propertyType": "select", - "options": ["", "ALWAYS"], - "defaultValue": "" - }, { "propertyName": "Expression", "propertyKeyword": "expression",