From 849c831d4deca3c660a49382c074414048baaafb Mon Sep 17 00:00:00 2001 From: Serhii Filonenko Date: Fri, 27 Sep 2024 14:21:30 +0300 Subject: [PATCH 1/2] HCK-8196: add PP config for column default ON NULL clause --- .../field_level/fieldLevelConfig.json | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/properties_pane/field_level/fieldLevelConfig.json b/properties_pane/field_level/fieldLevelConfig.json index 352f644..238a363 100644 --- a/properties_pane/field_level/fieldLevelConfig.json +++ b/properties_pane/field_level/fieldLevelConfig.json @@ -782,6 +782,40 @@ making sure that you maintain a proper JSON format. ] } }, + { + "propertyName": "On null", + "propertyKeyword": "defaultOnNull", + "propertyType": "checkbox", + "dependency": { + "type": "and", + "values": [ + { + "key": "default", + "pattern": "^[\\s\\S]+$" + }, + { + "type": "not", + "values": [ + { + "type": "and", + "values": [ + { + "level": "root", + "key": "viewOn", + "exist": true + }, + { + "level": "root", + "key": "duality", + "value": true + } + ] + } + ] + } + ] + } + }, { "propertyName": "Comments", "propertyKeyword": "description", @@ -2511,6 +2545,40 @@ making sure that you maintain a proper JSON format. ] } }, + { + "propertyName": "On null", + "propertyKeyword": "defaultOnNull", + "propertyType": "checkbox", + "dependency": { + "type": "and", + "values": [ + { + "key": "default", + "pattern": "^[\\s\\S]+$" + }, + { + "type": "not", + "values": [ + { + "type": "and", + "values": [ + { + "level": "root", + "key": "viewOn", + "exist": true + }, + { + "level": "root", + "key": "duality", + "value": true + } + ] + } + ] + } + ] + } + }, { "propertyName": "Comments", "propertyKeyword": "description", @@ -5176,6 +5244,53 @@ making sure that you maintain a proper JSON format. ] } }, + { + "propertyName": "On null", + "propertyKeyword": "defaultOnNull", + "propertyType": "checkbox", + "dependency": { + "type": "and", + "values": [ + { + "key": "default", + "pattern": "^[\\s\\S]+$" + }, + { + "type": "or", + "values": [ + { + "key": "now", + "value": false + }, + { + "key": "now", + "exist": false + } + ] + }, + { + "type": "not", + "values": [ + { + "type": "and", + "values": [ + { + "level": "root", + "key": "viewOn", + "exist": true + }, + { + "level": "root", + "key": "duality", + "value": true + } + ] + } + ] + } + ] + } + }, { "fieldKeyword": "enum", "dependency": { @@ -9706,6 +9821,40 @@ making sure that you maintain a proper JSON format. ] } }, + { + "propertyName": "On null", + "propertyKeyword": "defaultOnNull", + "propertyType": "checkbox", + "dependency": { + "type": "and", + "values": [ + { + "key": "default", + "pattern": "^[\\s\\S]+$" + }, + { + "type": "not", + "values": [ + { + "type": "and", + "values": [ + { + "level": "root", + "key": "viewOn", + "exist": true + }, + { + "level": "root", + "key": "duality", + "value": true + } + ] + } + ] + } + ] + } + }, { "fieldKeyword": "enum", "dependency": { @@ -10757,6 +10906,40 @@ making sure that you maintain a proper JSON format. "template": "textarea" }, "default", + { + "propertyName": "On null", + "propertyKeyword": "defaultOnNull", + "propertyType": "checkbox", + "dependency": { + "type": "and", + "values": [ + { + "key": "default", + "pattern": "^[\\s\\S]+$" + }, + { + "type": "not", + "values": [ + { + "type": "and", + "values": [ + { + "level": "root", + "key": "viewOn", + "exist": true + }, + { + "level": "root", + "key": "duality", + "value": true + } + ] + } + ] + } + ] + } + }, "sample", { "propertyName": "Remarks", From 61d5e44727168189ba422fc2f8850bc064fc6473 Mon Sep 17 00:00:00 2001 From: Serhii Filonenko Date: Fri, 27 Sep 2024 14:22:08 +0300 Subject: [PATCH 2/2] HCK-8196: adjust FE script for displying default ON NULL clause --- .../ddlProvider/ddlHelpers/columnDefinitionHelper.js | 8 +++++--- forward_engineering/ddlProvider/ddlProvider.js | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js b/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js index 63b0b3e..ac1b7bc 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/columnDefinitionHelper.js @@ -55,7 +55,7 @@ module.exports = ({ _, wrap, assignTemplates, templates, commentIfDeactivated, w return type; }; - const getColumnDefault = ({ default: defaultValue, identity }) => { + const getColumnDefault = ({ default: defaultValue, defaultOnNull, identity }) => { if (!_.isEmpty(identity) && identity.generated) { const getGenerated = ({ generated, generatedOnNull }) => { if (generated === 'BY DEFAULT') { @@ -73,8 +73,10 @@ module.exports = ({ _, wrap, assignTemplates, templates, commentIfDeactivated, w }; return ` GENERATED${getGenerated(identity)} AS IDENTITY (${_.trim(getOptions(identity))})`; - } else if (defaultValue) { - return ` DEFAULT ${defaultValue}`; + } else if (defaultValue || defaultValue === 0) { + const onNull = defaultOnNull ? ' ON NULL' : ''; + + return ` DEFAULT${onNull} ${defaultValue}`; } return ''; }; diff --git a/forward_engineering/ddlProvider/ddlProvider.js b/forward_engineering/ddlProvider/ddlProvider.js index 2ecd844..55886e4 100644 --- a/forward_engineering/ddlProvider/ddlProvider.js +++ b/forward_engineering/ddlProvider/ddlProvider.js @@ -214,6 +214,7 @@ module.exports = (baseProvider, options, app) => { isUDTRef, dimension: jsonSchema.dimension, subtype: jsonSchema.subtype, + defaultOnNull: jsonSchema.defaultOnNull, ...(canHaveIdentity(jsonSchema.mode) && { identity: jsonSchema.identity }), }; },