Skip to content

Commit a3527f4

Browse files
authored
Merge pull request #1 from DrMyroslav/HCK-1256-references-to-definitions-are-forwarded
add to script plain type of definitions
2 parents fc7d426 + a7be3e3 commit a3527f4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

forward_engineering/ddlProvider.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = (baseProvider, options, app) => {
5959
getColumnsList,
6060
});
6161

62-
const { getUserDefinedType } = require('./helpers/udtHelper')({
62+
const { getUserDefinedType, isNotPlainType } = require('./helpers/udtHelper')({
6363
_,
6464
commentIfDeactivated,
6565
assignTemplates,
@@ -525,6 +525,15 @@ module.exports = (baseProvider, options, app) => {
525525
};
526526
},
527527

528+
hydrateJsonSchemaColumn(jsonSchema, definitionJsonSchema) {
529+
if (!jsonSchema.$ref || _.isEmpty(definitionJsonSchema) || isNotPlainType(definitionJsonSchema)) {
530+
return jsonSchema;
531+
}
532+
533+
jsonSchema = _.omit(jsonSchema, '$ref');
534+
return { ...definitionJsonSchema, ...jsonSchema };
535+
},
536+
528537
hydrateIndex(indexData, tableData, schemaData) {
529538
return { ...indexData, schemaName: schemaData.schemaName };
530539
},

forward_engineering/helpers/udtHelper.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = ({
66
getNamePrefixedWithSchemaName,
77
wrapComment,
88
}) => {
9+
const notPlainTypes = ['composite', 'enum', 'range_udt', 'domain'];
910
const getPlainUdt = (udt, columns) => {
1011
const udtName = getNamePrefixedWithSchemaName(udt.name, udt.schemaName);
1112
const comment = assignTemplates(templates.comment, {
@@ -56,6 +57,10 @@ module.exports = ({
5657
}
5758
};
5859

60+
const isNotPlainType = (definitionJsonSchema) => {
61+
return notPlainTypes.includes(definitionJsonSchema.type);
62+
};
63+
5964
const getRangeOptions = udt => {
6065
const wrap = value => (value ? `\t${value}` : '');
6166

@@ -95,5 +100,5 @@ module.exports = ({
95100
});
96101
};
97102

98-
return { getUserDefinedType };
103+
return { getUserDefinedType, isNotPlainType };
99104
};

0 commit comments

Comments
 (0)