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 }), }; }, 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",