Skip to content

Commit

Permalink
HCK-8196: add PP config and support for column default on null clause…
Browse files Browse the repository at this point in the history
… in script (#138)

* HCK-8196: add PP config for column default ON NULL clause

* HCK-8196: adjust FE script for displying default ON NULL clause
  • Loading branch information
serhii-filonenko authored Sep 27, 2024
1 parent 58b4c2d commit a45f532
Show file tree
Hide file tree
Showing 3 changed files with 189 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
183 changes: 183 additions & 0 deletions properties_pane/field_level/fieldLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit a45f532

Please sign in to comment.