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