Skip to content

Commit

Permalink
HCK-8196: adjust FE script for displying default ON NULL clause
Browse files Browse the repository at this point in the history
  • Loading branch information
serhii-filonenko committed Sep 27, 2024
1 parent 849c831 commit 61d5e44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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 '';
};
Expand Down
1 change: 1 addition & 0 deletions forward_engineering/ddlProvider/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
};
},
Expand Down

0 comments on commit 61d5e44

Please sign in to comment.